]> git.immae.eu Git - github/shaarli/Shaarli.git/commitdiff
Merge pull request #1525 from ArthurHoaro/feature/rest-api-bookmark-dates
authorArthurHoaro <arthur@hoa.ro>
Tue, 13 Oct 2020 10:26:01 +0000 (12:26 +0200)
committerGitHub <noreply@github.com>
Tue, 13 Oct 2020 10:26:01 +0000 (12:26 +0200)
REST API: allow override of creation and update dates

1  2 
tests/api/controllers/links/PostLinkTest.php

index fe3de66ff13e2e6718542335e9bd22a797e5bb85,f969fe1cee6fa7856f1e516bf712ecf82f134965..20694571de7857415e71c15fd2cb09d8fc6593ef
@@@ -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);
      /**
       * After every test, remove the test datastore.
       */
 -    public function tearDown()
 +    protected function tearDown(): void
      {
          @unlink(self::$testDatastore);
          @unlink(self::$testHistory);
              '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',
          $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']);
      }
  
      /**