TestCase.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. namespace Alchemy\Zippy\Tests;
  3. use Alchemy\Zippy\Resource\ResourceCollection;
  4. use Alchemy\Zippy\Resource\Resource;
  5. abstract class TestCase extends \PHPUnit_Framework_TestCase
  6. {
  7. public static function getResourcesPath()
  8. {
  9. return __DIR__ . '/../../../resources';
  10. }
  11. protected function getResourceManagerMock($context = '', $elements = array())
  12. {
  13. $elements = array_map(function ($item) {
  14. return new Resource($item, $item);
  15. }, $elements);
  16. $collection = new ResourceCollection($context, $elements);
  17. $manager = $this
  18. ->getMockBuilder('Alchemy\Zippy\Resource\ResourceManager')
  19. ->disableOriginalConstructor()
  20. ->getMock();
  21. $manager->expects($this->any())
  22. ->method('handle')
  23. ->will($this->returnValue($collection));
  24. return $manager;
  25. }
  26. protected function getResource($data = null)
  27. {
  28. $resource = $this->getMock('Alchemy\Zippy\Adapter\Resource\ResourceInterface');
  29. if (null !== $data) {
  30. $resource->expects($this->any())
  31. ->method('getResource')
  32. ->will($this->returnValue($data));
  33. }
  34. return $resource;
  35. }
  36. }