ResourceTest.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. namespace Alchemy\Zippy\Tests\Resource;
  3. use Alchemy\Zippy\Resource\Resource;
  4. use Alchemy\Zippy\Tests\TestCase;
  5. class ResourceTest extends TestCase
  6. {
  7. /**
  8. * @covers Alchemy\Zippy\Resource\Resource::__construct
  9. * @covers Alchemy\Zippy\Resource\Resource::getTarget
  10. * @covers Alchemy\Zippy\Resource\Resource::getOriginal
  11. */
  12. public function testGetTargetAndOriginal()
  13. {
  14. $original = 'original-style';
  15. $target = 'target-fishnet';
  16. $resource = new Resource($original, $target);
  17. $this->assertEquals($original, $resource->getOriginal());
  18. $this->assertEquals($target, $resource->getTarget());
  19. }
  20. /**
  21. * @covers Alchemy\Zippy\Resource\Resource::canBeProcessedInPlace
  22. * @dataProvider provideProcessInPlaceData
  23. */
  24. public function testCanBeProcessedInPlace($expected, $context, $original, $target)
  25. {
  26. $resource = new Resource($original, $target);
  27. $this->assertInternalType('boolean', $resource->canBeProcessedInPlace($context));
  28. $this->assertEquals($expected, $resource->canBeProcessedInPlace($context));
  29. }
  30. public function provideProcessInPlaceData()
  31. {
  32. return array(
  33. array(true, '/path/to', '/path/to/file1', 'file1'),
  34. array(true, __DIR__, __FILE__, basename(__FILE__)),
  35. array(false, __DIR__, fopen(__FILE__, 'rb'), basename(__FILE__)),
  36. array(false, '/path/to', 'ftp:///path/to/file1', 'file1'),
  37. array(false, '/path/to', '/path/file1', 'file1'),
  38. array(false, '/path/to', 'file:///path/file1', 'file1'),
  39. array(true, '/path', '/path/to/file1', 'to/file1'),
  40. array(true, '/path/to', '/path/to/subdir/file2', 'subdir/file2'),
  41. array(true, '/path/to', 'file:///path/to/subdir/file2', 'subdir/file2'),
  42. );
  43. }
  44. }