Skip to content

Commit

Permalink
Unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Elisea Cornejo committed Mar 4, 2016
1 parent 881bfb6 commit 52c216e
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions tests/RegistryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,26 @@ public function testPersist()
$registry->persist();
}


public function testPersistNull()
{
$firstEntity = null;

$persister = $this->getMock('\eBayEnterprise\Behat\RegistryExtension\Persister');
$persister->expects($this->at(0))
->method('beginTransaction');

$persister->expects($this->never())
->method('persist');

$persister->expects($this->at(1))
->method('commitTransaction');

$registry = new Registry($persister);
$registry->append($firstEntity);
$registry->persist();
}

public function testPersistWithoutPersister()
{
$this->setExpectedException('InvalidArgumentException');
Expand Down Expand Up @@ -78,6 +98,25 @@ public function testCleanWithoutPersister()
$this->assertEquals(array(), $registry->getArrayCopy());
}

public function testCleanNull()
{
$firstEntity = null;

$persister = $this->getMock('\eBayEnterprise\Behat\RegistryExtension\Persister');
$persister->expects($this->at(0))
->method('beginTransaction');

$persister->expects($this->never())
->method('remove');

$persister->expects($this->at(1))
->method('commitTransaction');

$registry = new Registry($persister);
$registry->append($firstEntity);
$registry->reset();
}

public function testReload()
{
$oldEntity = new \stdClass();
Expand All @@ -96,6 +135,19 @@ public function testReload()
$this->assertSame($newEntity, $registry->findOne(get_class($oldEntity)));
}

public function testReloadNull()
{
$oldEntity = null;

$persister = $this->getMock('\eBayEnterprise\Behat\RegistryExtension\Persister');
$persister->expects($this->never())
->method('reload');

$registry = new Registry($persister);
$registry->append($oldEntity);
$registry->reload();
}

public function testMergeWithArray()
{
$firstEntity = new \stdClass();
Expand Down

0 comments on commit 52c216e

Please sign in to comment.