aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/api/controllers/PostLinkTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/api/controllers/PostLinkTest.php')
-rw-r--r--tests/api/controllers/PostLinkTest.php23
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/api/controllers/PostLinkTest.php b/tests/api/controllers/PostLinkTest.php
index 3ed7bcb0..31954e39 100644
--- a/tests/api/controllers/PostLinkTest.php
+++ b/tests/api/controllers/PostLinkTest.php
@@ -24,6 +24,11 @@ class PostLinkTest extends \PHPUnit_Framework_TestCase
24 protected static $testDatastore = 'sandbox/datastore.php'; 24 protected static $testDatastore = 'sandbox/datastore.php';
25 25
26 /** 26 /**
27 * @var string datastore to test write operations
28 */
29 protected static $testHistory = 'sandbox/history.php';
30
31 /**
27 * @var ConfigManager instance 32 * @var ConfigManager instance
28 */ 33 */
29 protected $conf; 34 protected $conf;
@@ -34,6 +39,11 @@ class PostLinkTest extends \PHPUnit_Framework_TestCase
34 protected $refDB = null; 39 protected $refDB = null;
35 40
36 /** 41 /**
42 * @var \History instance.
43 */
44 protected $history;
45
46 /**
37 * @var Container instance. 47 * @var Container instance.
38 */ 48 */
39 protected $container; 49 protected $container;
@@ -57,9 +67,14 @@ class PostLinkTest extends \PHPUnit_Framework_TestCase
57 $this->refDB = new \ReferenceLinkDB(); 67 $this->refDB = new \ReferenceLinkDB();
58 $this->refDB->write(self::$testDatastore); 68 $this->refDB->write(self::$testDatastore);
59 69
70 $refHistory = new \ReferenceHistory();
71 $refHistory->write(self::$testHistory);
72 $this->history = new \History(self::$testHistory);
73
60 $this->container = new Container(); 74 $this->container = new Container();
61 $this->container['conf'] = $this->conf; 75 $this->container['conf'] = $this->conf;
62 $this->container['db'] = new \LinkDB(self::$testDatastore, true, false); 76 $this->container['db'] = new \LinkDB(self::$testDatastore, true, false);
77 $this->container['history'] = new \History(self::$testHistory);
63 78
64 $this->controller = new Links($this->container); 79 $this->controller = new Links($this->container);
65 80
@@ -85,6 +100,7 @@ class PostLinkTest extends \PHPUnit_Framework_TestCase
85 public function tearDown() 100 public function tearDown()
86 { 101 {
87 @unlink(self::$testDatastore); 102 @unlink(self::$testDatastore);
103 @unlink(self::$testHistory);
88 } 104 }
89 105
90 /** 106 /**
@@ -112,6 +128,13 @@ class PostLinkTest extends \PHPUnit_Framework_TestCase
112 $this->assertEquals(false, $data['private']); 128 $this->assertEquals(false, $data['private']);
113 $this->assertTrue(new \DateTime('5 seconds ago') < \DateTime::createFromFormat(\DateTime::ATOM, $data['created'])); 129 $this->assertTrue(new \DateTime('5 seconds ago') < \DateTime::createFromFormat(\DateTime::ATOM, $data['created']));
114 $this->assertEquals('', $data['updated']); 130 $this->assertEquals('', $data['updated']);
131
132 $historyEntry = $this->history->getHistory()[0];
133 $this->assertEquals(\History::CREATED, $historyEntry['event']);
134 $this->assertTrue(
135 (new \DateTime())->add(\DateInterval::createFromDateString('-5 seconds')) < $historyEntry['datetime']
136 );
137 $this->assertEquals(43, $historyEntry['id']);
115 } 138 }
116 139
117 /** 140 /**