for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php declare(strict_types=1);
namespace Sunrise\Hydrator\Tests;
/**
* Import classes
*/
use PHPUnit\Framework\TestCase;
use Sunrise\Hydrator\HydrableObjectCollection;
use Sunrise\Hydrator\HydrableObjectCollectionInterface;
use InvalidArgumentException;
* HydrableObjectCollectionTest
class HydrableObjectCollectionTest extends TestCase
{
* @return void
public function testContracts() : void
$collection = new HydrableObjectCollection();
$this->assertInstanceOf(HydrableObjectCollectionInterface::class, $collection);
}
public function testAdd() : void
$store = [
new Fixture\BarDto(),
];
$collection->add($store[0]);
$collection->add($store[1]);
$collection->add($store[2]);
$this->assertSame($store, $collection->getIterator()->getArrayCopy());
public function testUnexpectedObject() : void
$collection = new Fixture\BarDtoCollection();
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('The <' . Fixture\BarDtoCollection::class . '> collection ' .
'must contain only the <' . Fixture\BarDto::class . '> objects.');
$collection->add(new Fixture\BazDto());