From: ArthurHoaro Date: Tue, 13 Oct 2020 10:26:01 +0000 (+0200) Subject: Merge pull request #1525 from ArthurHoaro/feature/rest-api-bookmark-dates X-Git-Tag: v0.12.1^2~42 X-Git-Url: https://git.immae.eu/?p=github%2Fshaarli%2FShaarli.git;a=commitdiff_plain;h=543b16b4f4bbde4e9857490e2175e44b4d941eb3;hp=-c Merge pull request #1525 from ArthurHoaro/feature/rest-api-bookmark-dates REST API: allow override of creation and update dates --- 543b16b4f4bbde4e9857490e2175e44b4d941eb3 diff --combined tests/api/controllers/links/PostLinkTest.php index fe3de66f,f969fe1c..20694571 --- a/tests/api/controllers/links/PostLinkTest.php +++ b/tests/api/controllers/links/PostLinkTest.php @@@ -2,11 -2,11 +2,11 @@@ namespace Shaarli\Api\Controllers; -use PHPUnit\Framework\TestCase; use Shaarli\Bookmark\Bookmark; use Shaarli\Bookmark\BookmarkFileService; use Shaarli\Config\ConfigManager; use Shaarli\History; +use Shaarli\TestCase; use Slim\Container; use Slim\Http\Environment; use Slim\Http\Request; @@@ -70,7 -70,7 +70,7 @@@ class PostLinkTest extends TestCas /** * 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'); $this->conf->set('resource.datastore', self::$testDatastore); @@@ -107,7 -107,7 +107,7 @@@ /** * After every test, remove the test datastore. */ - public function tearDown() + protected function tearDown(): void { @unlink(self::$testDatastore); @unlink(self::$testHistory); @@@ -160,6 -160,8 +160,8 @@@ 'description' => 'shaare description', 'tags' => ['one', 'two'], 'private' => true, + 'created' => '2015-05-05T12:30:00+03:00', + 'updated' => '2016-06-05T14:32:10+03:00', ]; $env = Environment::mock([ 'REQUEST_METHOD' => 'POST', @@@ -181,10 -183,8 +183,8 @@@ $this->assertEquals($link['description'], $data['description']); $this->assertEquals($link['tags'], $data['tags']); $this->assertEquals(true, $data['private']); - $this->assertTrue( - new \DateTime('2 seconds ago') < \DateTime::createFromFormat(\DateTime::ATOM, $data['created']) - ); - $this->assertEquals('', $data['updated']); + $this->assertSame($link['created'], $data['created']); + $this->assertSame($link['updated'], $data['updated']); } /**