1<?php 2require_once('..' . DIRECTORY_SEPARATOR . 'ZoteroRepository.php'); 3 4abstract class ZoteroRepositoryTest extends PHPUnit_Framework_TestCase 5{ 6 private $existingEntries = array(); 7 private $nonExistingEntry; 8 9 /** 10 * @var ZoteroRepository 11 */ 12 protected $r; 13 14 public function __construct() 15 { 16 $e = new ZoteroEntry("ABC123"); 17 $e->setAuthor("Stefan Macke"); 18 $e->setCiteKey("Macke2011"); 19 $e->setDate("2011"); 20 $e->setTitle("A nice book"); 21 $this->existingEntries[0] = $e; 22 23 $e = new ZoteroEntry("BCD234"); 24 $e->setAuthor("Stefan Werner"); 25 $e->setCiteKey("Werner2012"); 26 $e->setDate("2012"); 27 $e->setTitle("A nicer book"); 28 $this->existingEntries[1] = $e; 29 30 $e = new ZoteroEntry("CDE345"); 31 $e->setCiteKey("Merkel2010"); 32 $this->nonExistingEntry = $e; 33 } 34 35 public function testExistingEntriesById() 36 { 37 foreach ($this->existingEntries as $expected) 38 { 39 $actual = $this->r->getEntryByID($expected->getZoteroId()); 40 $this->assertTrue($expected->equals($actual)); 41 } 42 } 43 44 /** 45 * @expectedException ZoteroEntryNotFoundException 46 */ 47 public function testNonExistingEntriesById() 48 { 49 $e = $this->r->getEntryByID($this->nonExistingEntry->getZoteroId()); 50 } 51 52 public function testExistingEntriesByKey() 53 { 54 foreach ($this->existingEntries as $expected) 55 { 56 $actual = $this->r->getEntryByCiteKey($expected->getCiteKey()); 57 $this->assertTrue($expected->equals($actual)); 58 } 59 } 60 61 /** 62 * @expectedException ZoteroEntryNotFoundException 63 */ 64 public function testNonExistingEntriesByKey() 65 { 66 $e = $this->r->getEntryByCiteKey($this->nonExistingEntry->getCiteKey()); 67 } 68} 69?>