<?php
-
namespace Shaarli\Api\Controllers;
-
use Shaarli\Config\ConfigManager;
+use Shaarli\History;
use Slim\Container;
use Slim\Http\Environment;
use Slim\Http\Request;
require_once 'tests/utils/ReferenceHistory.php';
-class HistoryTest extends \PHPUnit_Framework_TestCase
+class HistoryTest extends \Shaarli\TestCase
{
/**
* @var string datastore to test write operations
protected $container;
/**
- * @var History controller instance.
+ * @var HistoryController controller instance.
*/
protected $controller;
/**
- * Before every test, instantiate a new Api with its config, plugins and links.
+ * Before every test, instantiate a new Api with its config, plugins and bookmarks.
*/
- public function setUp()
+ protected function setUp(): void
{
- $this->conf = new ConfigManager('tests/utils/config/configJson.json.php');
+ $this->conf = new ConfigManager('tests/utils/config/configJson');
$this->refHistory = new \ReferenceHistory();
$this->refHistory->write(self::$testHistory);
$this->container = new Container();
$this->container['conf'] = $this->conf;
$this->container['db'] = true;
- $this->container['history'] = new \History(self::$testHistory);
+ $this->container['history'] = new History(self::$testHistory);
- $this->controller = new History($this->container);
+ $this->controller = new HistoryController($this->container);
}
/**
* After every test, remove the test datastore.
*/
- public function tearDown()
+ protected function tearDown(): void
{
@unlink(self::$testHistory);
}
$this->assertEquals($this->refHistory->count(), count($data));
- $this->assertEquals(\History::DELETED, $data[0]['event']);
+ $this->assertEquals(History::DELETED, $data[0]['event']);
$this->assertEquals(
\DateTime::createFromFormat('Ymd_His', '20170303_121216')->format(\DateTime::ATOM),
$data[0]['datetime']
);
$this->assertEquals(124, $data[0]['id']);
- $this->assertEquals(\History::SETTINGS, $data[1]['event']);
+ $this->assertEquals(History::SETTINGS, $data[1]['event']);
$this->assertEquals(
\DateTime::createFromFormat('Ymd_His', '20170302_121215')->format(\DateTime::ATOM),
$data[1]['datetime']
);
$this->assertNull($data[1]['id']);
- $this->assertEquals(\History::UPDATED, $data[2]['event']);
+ $this->assertEquals(History::UPDATED, $data[2]['event']);
$this->assertEquals(
\DateTime::createFromFormat('Ymd_His', '20170301_121214')->format(\DateTime::ATOM),
$data[2]['datetime']
);
$this->assertEquals(123, $data[2]['id']);
- $this->assertEquals(\History::CREATED, $data[3]['event']);
+ $this->assertEquals(History::CREATED, $data[3]['event']);
$this->assertEquals(
\DateTime::createFromFormat('Ymd_His', '20170201_121214')->format(\DateTime::ATOM),
$data[3]['datetime']
);
$this->assertEquals(124, $data[3]['id']);
- $this->assertEquals(\History::CREATED, $data[4]['event']);
+ $this->assertEquals(History::CREATED, $data[4]['event']);
$this->assertEquals(
\DateTime::createFromFormat('Ymd_His', '20170101_121212')->format(\DateTime::ATOM),
$data[4]['datetime']
$this->assertEquals(1, count($data));
- $this->assertEquals(\History::DELETED, $data[0]['event']);
+ $this->assertEquals(History::DELETED, $data[0]['event']);
$this->assertEquals(
\DateTime::createFromFormat('Ymd_His', '20170303_121216')->format(\DateTime::ATOM),
$data[0]['datetime']
$this->assertEquals(1, count($data));
- $this->assertEquals(\History::CREATED, $data[0]['event']);
+ $this->assertEquals(History::CREATED, $data[0]['event']);
$this->assertEquals(
\DateTime::createFromFormat('Ymd_His', '20170101_121212')->format(\DateTime::ATOM),
$data[0]['datetime']
$this->assertEquals(1, count($data));
- $this->assertEquals(\History::DELETED, $data[0]['event']);
+ $this->assertEquals(History::DELETED, $data[0]['event']);
$this->assertEquals(
\DateTime::createFromFormat('Ymd_His', '20170303_121216')->format(\DateTime::ATOM),
$data[0]['datetime']
$this->assertEquals(1, count($data));
- $this->assertEquals(\History::SETTINGS, $data[0]['event']);
+ $this->assertEquals(History::SETTINGS, $data[0]['event']);
$this->assertEquals(
\DateTime::createFromFormat('Ymd_His', '20170302_121215')->format(\DateTime::ATOM),
$data[0]['datetime']