MemberTest.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <?php
  2. namespace Alchemy\Zippy\Tests\Archive;
  3. use Alchemy\Zippy\Tests\TestCase;
  4. use Alchemy\Zippy\Archive\Member;
  5. use Alchemy\Zippy\Archive\MemberInterface;
  6. class MemberTest extends TestCase
  7. {
  8. public function testNewInstance()
  9. {
  10. $member = new Member(
  11. $this->getResource('archive/located/here'),
  12. $this->getMock('Alchemy\Zippy\Adapter\AdapterInterface'),
  13. 'location',
  14. 1233456,
  15. new \DateTime("2012-07-08 11:14:15"),
  16. true
  17. );
  18. $this->assertTrue($member instanceof MemberInterface);
  19. return $member;
  20. }
  21. /**
  22. * @depends testNewInstance
  23. */
  24. public function testGetLocation($member)
  25. {
  26. $this->assertEquals('location', $member->getLocation());
  27. }
  28. /**
  29. * @depends testNewInstance
  30. */
  31. public function testIsDir($member)
  32. {
  33. $this->assertTrue($member->isDir());
  34. }
  35. /**
  36. * @depends testNewInstance
  37. */
  38. public function testGetLastModifiedDate($member)
  39. {
  40. $this->assertEquals(new \DateTime("2012-07-08 11:14:15"), $member->getLastModifiedDate());
  41. }
  42. /**
  43. * @depends testNewInstance
  44. */
  45. public function testGetSize($member)
  46. {
  47. $this->assertEquals(1233456, $member->getSize());
  48. }
  49. /**
  50. * @depends testNewInstance
  51. */
  52. public function testToString($member)
  53. {
  54. $this->assertEquals('location', (string) $member);
  55. }
  56. public function testExtract()
  57. {
  58. $mockAdapter = $this->getMock('Alchemy\Zippy\Adapter\AdapterInterface');
  59. $mockAdapter
  60. ->expects($this->any())
  61. ->method('extractMembers');
  62. $member = new Member(
  63. $this->getResource('archive/located/here'),
  64. $mockAdapter,
  65. '/member/located/here',
  66. 1233456,
  67. new \DateTime("2012-07-08 11:14:15"),
  68. true
  69. );
  70. $file = $member->extract();
  71. $this->assertEquals(sprintf('%s%s', getcwd(), '/member/located/here'), $file->getPathname());
  72. $file = $member->extract('/custom/location');
  73. $this->assertEquals('/custom/location/member/located/here', $file->getPathname());
  74. }
  75. }