use Shaarli\Bookmark\Bookmark;
use Shaarli\Bookmark\BookmarkFileService;
use Shaarli\Config\ConfigManager;
use Shaarli\Bookmark\Bookmark;
use Shaarli\Bookmark\BookmarkFileService;
use Shaarli\Config\ConfigManager;
$this->conf = new ConfigManager('tests/utils/config/configJson');
$this->conf->set('resource.datastore', self::$testDatastore);
$this->refDB = new \ReferenceLinkDB();
$this->conf = new ConfigManager('tests/utils/config/configJson');
$this->conf->set('resource.datastore', self::$testDatastore);
$this->refDB = new \ReferenceLinkDB();
$refHistory = new \ReferenceHistory();
$refHistory->write(self::$testHistory);
$this->history = new History(self::$testHistory);
$refHistory = new \ReferenceHistory();
$refHistory->write(self::$testHistory);
$this->history = new History(self::$testHistory);
- $this->bookmarkService = new BookmarkFileService($this->conf, $this->history, true);
+ $this->bookmarkService = new BookmarkFileService($this->conf, $this->history, $mutex, true);
$response = $this->controller->postLink($request, new Response());
$this->assertEquals(201, $response->getStatusCode());
$response = $this->controller->postLink($request, new Response());
$this->assertEquals(201, $response->getStatusCode());
$data = json_decode((string) $response->getBody(), true);
$this->assertEquals(self::NB_FIELDS_LINK, count($data));
$this->assertEquals(43, $data['id']);
$data = json_decode((string) $response->getBody(), true);
$this->assertEquals(self::NB_FIELDS_LINK, count($data));
$this->assertEquals(43, $data['id']);
'description' => 'shaare description',
'tags' => ['one', 'two'],
'private' => true,
'description' => 'shaare description',
'tags' => ['one', 'two'],
'private' => true,
];
$env = Environment::mock([
'REQUEST_METHOD' => 'POST',
];
$env = Environment::mock([
'REQUEST_METHOD' => 'POST',
$response = $this->controller->postLink($request, new Response());
$this->assertEquals(201, $response->getStatusCode());
$response = $this->controller->postLink($request, new Response());
$this->assertEquals(201, $response->getStatusCode());
$data = json_decode((string) $response->getBody(), true);
$this->assertEquals(self::NB_FIELDS_LINK, count($data));
$this->assertEquals(43, $data['id']);
$data = json_decode((string) $response->getBody(), true);
$this->assertEquals(self::NB_FIELDS_LINK, count($data));
$this->assertEquals(43, $data['id']);
$this->assertEquals($link['description'], $data['description']);
$this->assertEquals($link['tags'], $data['tags']);
$this->assertEquals(true, $data['private']);
$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']);