pull/41/head
Laurent Cozic 2017-06-04 00:21:15 +01:00
parent 9612327fb2
commit 7c43f38be5
5 changed files with 14 additions and 11 deletions

View File

@ -1,6 +1,7 @@
#!/bin/bash
# php phpunit-5.7.20.phar --bootstrap vendor/autoload.php tests/Model/
# php phpunit-5.7.20.phar --filter testConflict ChangeTest tests/Model/ChangeTest.php --bootstrap vendor/autoload.php tests/Model/
# php phpunit-5.7.20.phar --filter SynchronizerControllerTest tests/Controller/SynchronizerControllerTest.php --bootstrap vendor/autoload.php tests/Controller/
php phpunit-5.7.20.phar --bootstrap vendor/autoload.php tests/Controller/
# Example to test just one method of a test unit:
# php phpunit-5.7.20.phar --filter testConflict ChangeTest tests/Model/ChangeTest.php --bootstrap vendor/autoload.php tests/Model/
php5.6 phpunit-5.7.20.phar --bootstrap vendor/autoload.php tests/Controller/
php5.6 phpunit-5.7.20.phar --bootstrap vendor/autoload.php tests/Model/

View File

@ -42,6 +42,9 @@ class FoldersController extends ApiController {
return static::successResponse($folder);
}
$query = $request->query->all();
if ($folder) $folder->revId = $query['rev_id'];
if ($request->isMethod('PUT')) {
$isNew = !$folder;
if ($isNew) $folder = new Folder();

View File

@ -38,6 +38,9 @@ class NotesController extends ApiController {
return static::successResponse($note);
}
$query = $request->query->all();
if ($note) $note->revId = $query['rev_id'];
if ($request->isMethod('PUT')) {
$isNew = !$note;
if ($isNew) $note = new Note();
@ -51,10 +54,6 @@ class NotesController extends ApiController {
}
if ($request->isMethod('PATCH')) {
$query = $request->query->all();
$note->id = Note::unhex($id);
$note->revId = $query['rev_id'];
$note->fromPublicArray($this->patchParameters());
$note->save();
return static::successResponse($note);

View File

@ -95,8 +95,8 @@ class SynchronizerControllerTest extends BaseControllerTestCase {
$this->loadSession(1, 2);
$syncResult2 = $this->request('GET', '/synchronizer', array('rev_id' => $client2_revId));
// In case of conflict, the string should be set to the last PATCH operation
$this->assertEquals('YYYYYYYYYY', $syncResult1['items'][0]['item']['title']);
// In case of conflict, the last non-conflicted version is returned
$this->assertEquals('XXXXXXXXXX', $syncResult1['items'][0]['item']['title']);
// TODO: handle conflict
}

View File

@ -196,7 +196,7 @@ class ChangeTest extends BaseTestCase {
$r = Change::changesDoneAfterId($this->userId(), $this->clientId(1), 0);
$this->assertCount(2, $r);
$this->assertCount(3, $r);
$this->assertFalse($r['has_more']);
$this->assertCount(0, $r['items']); // Since client 1 is the one that made the changes, no sync data needs to be returned