FileTest.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. namespace Transmission\Tests\Model;
  3. use Transmission\Model\File;
  4. use Transmission\Util\PropertyMapper;
  5. class FileTest extends \PHPUnit_Framework_TestCase
  6. {
  7. protected $file;
  8. /**
  9. * @test
  10. */
  11. public function shouldImplementModelInterface()
  12. {
  13. $this->assertInstanceOf('Transmission\Model\ModelInterface', $this->getFile());
  14. }
  15. /**
  16. * @test
  17. */
  18. public function shouldHaveNonEmptyMapping()
  19. {
  20. $this->assertNotEmpty($this->getFile()->getMapping());
  21. }
  22. /**
  23. * @test
  24. */
  25. public function shouldBeCreatedFromMapping()
  26. {
  27. $source = (object) array(
  28. 'name' => 'foo',
  29. 'length' => 100,
  30. 'bytesCompleted' => 10
  31. );
  32. PropertyMapper::map($this->getFile(), $source);
  33. $this->assertEquals('foo', $this->getFile()->getName());
  34. $this->assertEquals(100, $this->getFile()->getSize());
  35. $this->assertEquals(10, $this->getFile()->getCompleted());
  36. $this->assertFalse($this->getFile()->isDone());
  37. }
  38. public function setup()
  39. {
  40. $this->file = new File();
  41. }
  42. private function getFile()
  43. {
  44. return $this->file;
  45. }
  46. }