From 61d406933e7311a3eb3c0379f1dea8b790459722 Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Sat, 6 May 2017 19:39:39 +0200 Subject: API: Get History endpoint See http://shaarli.github.io/api-documentation/#links-history-get --- tests/utils/ReferenceHistory.php | 82 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 tests/utils/ReferenceHistory.php (limited to 'tests/utils/ReferenceHistory.php') diff --git a/tests/utils/ReferenceHistory.php b/tests/utils/ReferenceHistory.php new file mode 100644 index 00000000..20284770 --- /dev/null +++ b/tests/utils/ReferenceHistory.php @@ -0,0 +1,82 @@ +addEntry( + History::CREATED, + DateTime::createFromFormat('Ymd_His', '20170101_121212'), + 123 + ); + + $this->addEntry( + History::CREATED, + DateTime::createFromFormat('Ymd_His', '20170201_121214'), + 124 + ); + + $this->addEntry( + History::UPDATED, + DateTime::createFromFormat('Ymd_His', '20170301_121214'), + 123 + ); + + $this->addEntry( + History::SETTINGS, + DateTime::createFromFormat('Ymd_His', '20170302_121215') + ); + + $this->addEntry( + History::DELETED, + DateTime::createFromFormat('Ymd_His', '20170303_121216'), + 124 + ); + } + + /** + * Adds a new history entry + * + * @param string $event Event identifier + * @param DateTime $datetime creation date + * @param int $id optional: related link ID + */ + protected function addEntry($event, $datetime, $id = null) + { + $link = [ + 'event' => $event, + 'datetime' => $datetime, + 'id' => $id, + ]; + $this->history[] = $link; + $this->count++; + } + + /** + * Writes data to the datastore + * + * @param string $filename write history content to. + */ + public function write($filename) + { + FileUtils::writeFlatDB($filename, $this->history); + } + + /** + * Returns the number of links in the reference data + */ + public function count() + { + return $this->count; + } +} -- cgit v1.2.3