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\ObjectCollection;
use Sunrise\Hydrator\ObjectCollectionInterface;
use InvalidArgumentException;
* ObjectCollectionTest
class ObjectCollectionTest extends TestCase
{
* @return void
public function testContracts() : void
$collection = new Fixtures\BarDtoCollection();
$this->assertInstanceOf(ObjectCollectionInterface::class, $collection);
}
public function testAdd() : void
$store = [
new Fixtures\BarDto(),
];
$collection->add(0, $store[0]);
$collection->add(1, $store[1]);
$collection->add(2, $store[2]);
$this->assertSame($store, $collection->all());
public function testUnexpectedObject() : void
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('The <' . Fixtures\BarDtoCollection::class . '> collection ' .
'must contain the <' . Fixtures\BarDto::class . '> objects only.');
$collection->add(0, new Fixtures\BazDto());