diff --git a/.gitignore b/.gitignore old mode 100644 new mode 100755 diff --git a/README.md b/README.md old mode 100644 new mode 100755 diff --git a/app/.htaccess b/app/.htaccess old mode 100644 new mode 100755 diff --git a/app/AppCache.php b/app/AppCache.php old mode 100644 new mode 100755 diff --git a/app/AppKernel.php b/app/AppKernel.php old mode 100644 new mode 100755 diff --git a/app/Resources/views/base.html.twig b/app/Resources/views/base.html.twig old mode 100644 new mode 100755 diff --git a/app/Resources/views/default/index.html.twig b/app/Resources/views/default/index.html.twig old mode 100644 new mode 100755 diff --git a/app/autoload.php b/app/autoload.php old mode 100644 new mode 100755 diff --git a/app/config/config.yml b/app/config/config.yml old mode 100644 new mode 100755 diff --git a/app/config/config_dev.yml b/app/config/config_dev.yml old mode 100644 new mode 100755 diff --git a/app/config/config_prod.yml b/app/config/config_prod.yml old mode 100644 new mode 100755 diff --git a/app/config/config_test.yml b/app/config/config_test.yml old mode 100644 new mode 100755 diff --git a/app/config/parameters.yml.dist b/app/config/parameters.yml.dist old mode 100644 new mode 100755 diff --git a/app/config/routing.yml b/app/config/routing.yml old mode 100644 new mode 100755 diff --git a/app/config/routing_dev.yml b/app/config/routing_dev.yml old mode 100644 new mode 100755 diff --git a/app/config/security.yml b/app/config/security.yml old mode 100644 new mode 100755 diff --git a/app/config/services.yml b/app/config/services.yml old mode 100644 new mode 100755 diff --git a/cli-client/.config1/config.json b/cli-client/.config1/config.json old mode 100644 new mode 100755 diff --git a/cli-client/.config2/config.json b/cli-client/.config2/config.json old mode 100644 new mode 100755 diff --git a/cli-client/main.go b/cli-client/main.go old mode 100644 new mode 100755 diff --git a/cli-client/main.php b/cli-client/main.php old mode 100644 new mode 100755 diff --git a/cli-client/test_11111111111111111111111111111111/folder1/my_note1.md b/cli-client/test_11111111111111111111111111111111/folder1/my_note1.md old mode 100644 new mode 100755 diff --git a/cli-client/test_11111111111111111111111111111111/folder2/my_note1.md b/cli-client/test_11111111111111111111111111111111/folder2/my_note1.md old mode 100644 new mode 100755 diff --git a/cli-client/test_11111111111111111111111111111111/folder2/my_note2.md b/cli-client/test_11111111111111111111111111111111/folder2/my_note2.md old mode 100644 new mode 100755 diff --git a/cli-client/test_11111111111111111111111111111111/folder2/sub/subnote.md b/cli-client/test_11111111111111111111111111111111/folder2/sub/subnote.md old mode 100644 new mode 100755 diff --git a/cli-client/test_22222222222222222222222222222222/folder1/my_note1.md b/cli-client/test_22222222222222222222222222222222/folder1/my_note1.md old mode 100644 new mode 100755 diff --git a/cli-client/test_22222222222222222222222222222222/folder2/my_note1.md b/cli-client/test_22222222222222222222222222222222/folder2/my_note1.md old mode 100644 new mode 100755 diff --git a/cli-client/test_22222222222222222222222222222222/folder2/my_note2.md b/cli-client/test_22222222222222222222222222222222/folder2/my_note2.md old mode 100644 new mode 100755 diff --git a/cli-client/test_22222222222222222222222222222222/folder2/sub/subnote.md b/cli-client/test_22222222222222222222222222222222/folder2/sub/subnote.md old mode 100644 new mode 100755 diff --git a/composer.json b/composer.json old mode 100644 new mode 100755 diff --git a/composer.lock b/composer.lock old mode 100644 new mode 100755 diff --git a/notes.sublime-project b/notes.sublime-project deleted file mode 100644 index 0ee13814f..000000000 --- a/notes.sublime-project +++ /dev/null @@ -1,11 +0,0 @@ -{ - "folders": - [ - { - "path": ".", - "folder_exclude_patterns": [ - "var" - ] - } - ] -} diff --git a/phpunit.xml.dist b/phpunit.xml.dist old mode 100644 new mode 100755 diff --git a/src/.htaccess b/src/.htaccess old mode 100644 new mode 100755 diff --git a/src/AppBundle/AppBundle.php b/src/AppBundle/AppBundle.php old mode 100644 new mode 100755 diff --git a/src/AppBundle/Controller/ApiController.php b/src/AppBundle/Controller/ApiController.php old mode 100644 new mode 100755 diff --git a/src/AppBundle/Controller/FoldersController.php b/src/AppBundle/Controller/FoldersController.php old mode 100644 new mode 100755 diff --git a/src/AppBundle/Controller/NotesController.php b/src/AppBundle/Controller/NotesController.php old mode 100644 new mode 100755 diff --git a/src/AppBundle/Controller/SessionsController.php b/src/AppBundle/Controller/SessionsController.php old mode 100644 new mode 100755 diff --git a/src/AppBundle/Controller/SynchronizerController.php b/src/AppBundle/Controller/SynchronizerController.php old mode 100644 new mode 100755 diff --git a/src/AppBundle/Controller/UsersController.php b/src/AppBundle/Controller/UsersController.php old mode 100644 new mode 100755 diff --git a/src/AppBundle/Diff.php b/src/AppBundle/Diff.php old mode 100644 new mode 100755 diff --git a/src/AppBundle/Eloquent.php b/src/AppBundle/Eloquent.php old mode 100644 new mode 100755 diff --git a/src/AppBundle/Exception/AuthException.php b/src/AppBundle/Exception/AuthException.php old mode 100644 new mode 100755 diff --git a/src/AppBundle/Exception/BaseException.php b/src/AppBundle/Exception/BaseException.php old mode 100644 new mode 100755 diff --git a/src/AppBundle/Exception/ForbiddenException.php b/src/AppBundle/Exception/ForbiddenException.php old mode 100644 new mode 100755 diff --git a/src/AppBundle/Exception/MethodNotAllowedException.php b/src/AppBundle/Exception/MethodNotAllowedException.php old mode 100644 new mode 100755 diff --git a/src/AppBundle/Exception/NotFoundException.php b/src/AppBundle/Exception/NotFoundException.php old mode 100644 new mode 100755 diff --git a/src/AppBundle/Exception/UnauthorizedException.php b/src/AppBundle/Exception/UnauthorizedException.php old mode 100644 new mode 100755 diff --git a/src/AppBundle/Exception/ValidationException.php b/src/AppBundle/Exception/ValidationException.php old mode 100644 new mode 100755 diff --git a/src/AppBundle/Model/Action.php b/src/AppBundle/Model/Action.php old mode 100644 new mode 100755 diff --git a/src/AppBundle/Model/BaseModel.php b/src/AppBundle/Model/BaseModel.php old mode 100644 new mode 100755 diff --git a/src/AppBundle/Model/Change.php b/src/AppBundle/Model/Change.php old mode 100644 new mode 100755 diff --git a/src/AppBundle/Model/Folder.php b/src/AppBundle/Model/Folder.php old mode 100644 new mode 100755 diff --git a/src/AppBundle/Model/FolderItem.php b/src/AppBundle/Model/FolderItem.php old mode 100644 new mode 100755 diff --git a/src/AppBundle/Model/Note.php b/src/AppBundle/Model/Note.php old mode 100644 new mode 100755 diff --git a/src/AppBundle/Model/Session.php b/src/AppBundle/Model/Session.php old mode 100644 new mode 100755 diff --git a/src/AppBundle/Model/User.php b/src/AppBundle/Model/User.php old mode 100644 new mode 100755 diff --git a/structure.sql b/structure.sql old mode 100644 new mode 100755 diff --git a/tests/BaseTestCase.php b/tests/BaseTestCase.php old mode 100644 new mode 100755 diff --git a/tests/Model/ChangeTest.php b/tests/Model/ChangeTest.php old mode 100644 new mode 100755 index 48c69d9db..e209f22ce --- a/tests/Model/ChangeTest.php +++ b/tests/Model/ChangeTest.php @@ -16,10 +16,6 @@ class ChangeTest extends BaseTestCase { Note::truncate(); } - public function tearDown() { - - } - public function testDiff() { $text1 = 'abcd efgh ijkl'; @@ -167,5 +163,51 @@ class ChangeTest extends BaseTestCase { $this->assertCount(1, $r['items']); } + + public function testMultiClients() { + // Simulates synchronization with multiple clients: + // - One client creates two notes. + // - Another client (but same user) creates three notes. + // - Check that sets of notes is the same for both clients. + + $clientNotes = array(1 => array(), 2 => array()); + + for ($clientId = 1; $clientId <= 2; $clientId++) { + BaseModel::setClientId($this->clientId($clientId)); + + $noteCount = $clientId == 1 ? 2 : 3; + for ($i = 1; $i <= $noteCount; $i++) { + $n = new Note(); + $n->fromPublicArray(array('body' => 'note C' . $clientId . ' - ' . $i)); + $n->owner_id = $this->userId(); + $n->save(); + + $clientNotes[$clientId][] = $n->toPublicArray(); + } + } + + for ($clientId = 1; $clientId <= 2; $clientId++) { + $r = Change::changesDoneAfterId($this->userId(), $this->clientId($clientId), 0); + $this->assertCount($clientId == 1 ? 3 : 2, $r['items']); + + foreach ($r['items'] as $item) { + $item = $item->toPublicArray(); + $this->assertEquals('create', $item['type']); + + $n = Note::find(BaseModel::unhex($item['item_id'])); + $clientNotes[$clientId][] = $n->toPublicArray(); + } + } + + $this->assertEquals(count($clientNotes[1]), count($clientNotes[2])); + + foreach ($clientNotes[1] as $n1) { + $foundCount = 0; + foreach ($clientNotes[2] as $n2) { + if ($n1['body'] === $n2['body']) $foundCount++; + } + $this->assertEquals(1, $foundCount); + } + } } \ No newline at end of file diff --git a/tests/Model/NoteTest.php b/tests/Model/NoteTest.php old mode 100644 new mode 100755 diff --git a/tests/setup.php b/tests/setup.php old mode 100644 new mode 100755 diff --git a/var/SymfonyRequirements.php b/var/SymfonyRequirements.php old mode 100644 new mode 100755 diff --git a/var/cache/.gitkeep b/var/cache/.gitkeep old mode 100644 new mode 100755 diff --git a/var/logs/.gitkeep b/var/logs/.gitkeep old mode 100644 new mode 100755 diff --git a/var/sessions/.gitkeep b/var/sessions/.gitkeep old mode 100644 new mode 100755 diff --git a/web/.htaccess b/web/.htaccess old mode 100644 new mode 100755 diff --git a/web/app.php b/web/app.php old mode 100644 new mode 100755 diff --git a/web/app_dev.php b/web/app_dev.php old mode 100644 new mode 100755 diff --git a/web/apple-touch-icon.png b/web/apple-touch-icon.png old mode 100644 new mode 100755 diff --git a/web/config.php b/web/config.php old mode 100644 new mode 100755 diff --git a/web/favicon.ico b/web/favicon.ico old mode 100644 new mode 100755 diff --git a/web/robots.txt b/web/robots.txt old mode 100644 new mode 100755