TrackerTest.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. namespace Transmission\Tests\Model;
  3. use Transmission\Model\Tracker;
  4. use Transmission\Util\PropertyMapper;
  5. class TrackerTest extends \PHPUnit_Framework_TestCase
  6. {
  7. protected $tracker;
  8. /**
  9. * @test
  10. */
  11. public function shouldImplementModelInterface()
  12. {
  13. $this->assertInstanceOf('Transmission\Model\ModelInterface', $this->getTracker());
  14. }
  15. /**
  16. * @test
  17. */
  18. public function shouldHaveNonEmptyMapping()
  19. {
  20. $this->assertNotEmpty($this->getTracker()->getMapping());
  21. }
  22. /**
  23. * @test
  24. */
  25. public function shouldBeCreatedFromMapping()
  26. {
  27. $source = (object) array(
  28. 'id' => 1,
  29. 'tier' => 1,
  30. 'scrape' => 'foo',
  31. 'announce' => 'bar'
  32. );
  33. PropertyMapper::map($this->getTracker(), $source);
  34. $this->assertEquals(1, $this->getTracker()->getId());
  35. $this->assertEquals(1, $this->getTracker()->getTier());
  36. $this->assertEquals('foo', $this->getTracker()->getScrape());
  37. $this->assertEquals('bar', $this->getTracker()->getAnnounce());
  38. }
  39. public function setup()
  40. {
  41. $this->tracker = new Tracker();
  42. }
  43. private function getTracker()
  44. {
  45. return $this->tracker;
  46. }
  47. }