Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
bakura10 committed Feb 17, 2014
1 parent edfd852 commit a0d973c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/ZfrRest/Mvc/Controller/Plugin/ResourceModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

use Doctrine\Common\Collections\Collection;
use Doctrine\Common\Collections\Criteria;
use DoctrineModule\Paginator\Adapter\Selectable;
use Doctrine\Common\Collections\Selectable;
use Zend\Mvc\Controller\Plugin\AbstractPlugin;
use ZfrRest\Mvc\Controller\AbstractRestfulController;
use ZfrRest\Mvc\Exception\RuntimeException;
Expand Down
21 changes: 21 additions & 0 deletions tests/ZfrRestTest/Mvc/Controller/Plugin/ResourceModelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,25 @@ public function testCanCreateResourceModelWithMetadata()
$this->assertSame($data, $resourceModel->getResource()->getData());
$this->assertSame($metadata, $resourceModel->getResource()->getMetadata());
}

public function testForceSelectableToBeCollectionIfNotAlready()
{
$controller = new AbstractRestfulController();
$plugin = new ResourceModel();
$plugin->setController($controller);

$metadata = $this->getMock('ZfrRest\Resource\Metadata\ResourceMetadataInterface');

$data = $this->getMock('Doctrine\Common\Collections\Selectable');
$data->expects($this->once())
->method('matching')
->with($this->isInstanceOf('Doctrine\Common\Collections\Criteria'))
->will($this->returnValue($this->getMock('Doctrine\Common\Collections\Collection')));

$resourceModel = $plugin($data, $metadata);

$this->assertInstanceOf('ZfrRest\View\Model\ResourceModel', $resourceModel);
//$this->assertInstanceOf('Doctrine\Common\Collections\Collection', $resourceModel->getResource()->getData());
$this->assertSame($metadata, $resourceModel->getResource()->getMetadata());
}
}

0 comments on commit a0d973c

Please sign in to comment.