Files
ezmigrationbundle/Tests/phpunit/0_CollectionsTest.php
2019-08-01 09:38:15 +00:00

62 lines
1.8 KiB
PHP

<?php
include_once(__DIR__.'/CommandTest.php');
use Kaliop\eZMigrationBundle\API\Collection\MigrationStepsCollection;
use Kaliop\eZMigrationBundle\API\Value\MigrationStep;
/**
* Tests the 'filtering' features of the collections. Plain usage as array is already tested by the rest of the suite
*/
class CollectionsTest extends CommandTest
{
public function testValidElements1()
{
$collection = new MigrationStepsCollection(array(new MigrationStep('test')));
}
public function testValidElements2()
{
$collection = new MigrationStepsCollection(array());
$collection[] = new MigrationStep('test');
}
public function testValidElements3()
{
$collection = new MigrationStepsCollection(array());
$collection['test'] = new MigrationStep('test');
}
public function testInvalidElements1()
{
$this->expectException('InvalidArgumentException');
$collection = new MigrationStepsCollection(array(1));
}
public function testInvalidElements2()
{
$collection = new MigrationStepsCollection(array());
$this->expectException('InvalidArgumentException');
$collection[] = 'not a content';
}
public function testInvalidElements3()
{
$collection = new MigrationStepsCollection(array());
$this->expectException('InvalidArgumentException');
$collection['test'] = true;
}
public function testExchangeArray()
{
$collection = new MigrationStepsCollection(array(new MigrationStep('test1')));
$collection->exchangeArray(array(new MigrationStep('test2')));
$this->assertEquals('test2', $collection[0]->type);
$this->expectException('InvalidArgumentException');
$collection->exchangeArray(array('hello'));
}
}