You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
59 lines
1.6 KiB
59 lines
1.6 KiB
10 years ago
|
<?php
|
||
|
|
||
|
/**
|
||
|
* @link http://www.yiiframework.com/
|
||
|
* @copyright Copyright (c) 2008 Yii Software LLC
|
||
|
* @license http://www.yiiframework.com/license/
|
||
|
*/
|
||
|
|
||
|
namespace yiiunit\framework\test;
|
||
|
|
||
|
use yiiunit\TestCase;
|
||
|
use yii\test\ArrayFixture;
|
||
|
|
||
|
class ArrayFixtureTest extends TestCase
|
||
|
{
|
||
|
|
||
|
/**
|
||
10 years ago
|
* @var \yii\test\ArrayFixture
|
||
10 years ago
|
*/
|
||
|
private $_fixture;
|
||
|
|
||
|
protected function setUp()
|
||
|
{
|
||
|
parent::setUp();
|
||
|
$this->_fixture = new ArrayFixture();
|
||
|
}
|
||
|
|
||
|
public function testLoadUnloadParticularFile()
|
||
|
{
|
||
|
$this->_fixture->dataFile = '@yiiunit/framework/test/data/array_fixture.php';
|
||
|
$this->assertEmpty($this->_fixture->data, 'fixture data should be empty');
|
||
|
|
||
|
$this->_fixture->load();
|
||
|
|
||
|
$this->assertCount(2, $this->_fixture->data, 'fixture data should match needed total count');
|
||
|
$this->assertEquals('customer1', $this->_fixture['customer1']['name'], 'first fixture data should match');
|
||
|
$this->assertEquals('customer2@example.com', $this->_fixture['customer2']['email'], 'second fixture data should match');
|
||
|
}
|
||
|
|
||
|
public function testNothingToLoad()
|
||
|
{
|
||
|
$this->_fixture->dataFile = false;
|
||
|
$this->assertEmpty($this->_fixture->data, 'fixture data should be empty');
|
||
|
|
||
|
$this->_fixture->load();
|
||
|
$this->assertEmpty($this->_fixture->data, 'fixture data should not be loaded');
|
||
|
}
|
||
|
|
||
|
/**
|
||
10 years ago
|
* @expectedException \yii\base\InvalidConfigException
|
||
10 years ago
|
*/
|
||
|
public function testWrongDataFileException()
|
||
|
{
|
||
10 years ago
|
$this->_fixture->dataFile = 'wrong/fixtures/data/path/alias';
|
||
10 years ago
|
$this->_fixture->load();
|
||
|
}
|
||
|
|
||
|
}
|