From 198fc4e85cdf290bfa4196aa43f9d23ee7acce5c Mon Sep 17 00:00:00 2001 From: Laurent Cozic Date: Sat, 10 Dec 2016 22:35:53 +0000 Subject: [PATCH] mod change --- .gitignore | 0 README.md | 0 app/.htaccess | 0 app/AppCache.php | 0 app/AppKernel.php | 0 app/Resources/views/base.html.twig | 0 app/Resources/views/default/index.html.twig | 0 app/autoload.php | 0 app/config/config.yml | 0 app/config/config_dev.yml | 0 app/config/config_prod.yml | 0 app/config/config_test.yml | 0 app/config/parameters.yml.dist | 0 app/config/routing.yml | 0 app/config/routing_dev.yml | 0 app/config/security.yml | 0 app/config/services.yml | 0 cli-client/.config1/config.json | 0 cli-client/.config2/config.json | 0 cli-client/main.go | 0 cli-client/main.php | 0 .../folder1/my_note1.md | 0 .../folder2/my_note1.md | 0 .../folder2/my_note2.md | 0 .../folder2/sub/subnote.md | 0 .../folder1/my_note1.md | 0 .../folder2/my_note1.md | 0 .../folder2/my_note2.md | 0 .../folder2/sub/subnote.md | 0 composer.json | 0 composer.lock | 0 notes.sublime-project | 11 ---- phpunit.xml.dist | 0 src/.htaccess | 0 src/AppBundle/AppBundle.php | 0 src/AppBundle/Controller/ApiController.php | 0 .../Controller/FoldersController.php | 0 src/AppBundle/Controller/NotesController.php | 0 .../Controller/SessionsController.php | 0 .../Controller/SynchronizerController.php | 0 src/AppBundle/Controller/UsersController.php | 0 src/AppBundle/Diff.php | 0 src/AppBundle/Eloquent.php | 0 src/AppBundle/Exception/AuthException.php | 0 src/AppBundle/Exception/BaseException.php | 0 .../Exception/ForbiddenException.php | 0 .../Exception/MethodNotAllowedException.php | 0 src/AppBundle/Exception/NotFoundException.php | 0 .../Exception/UnauthorizedException.php | 0 .../Exception/ValidationException.php | 0 src/AppBundle/Model/Action.php | 0 src/AppBundle/Model/BaseModel.php | 0 src/AppBundle/Model/Change.php | 0 src/AppBundle/Model/Folder.php | 0 src/AppBundle/Model/FolderItem.php | 0 src/AppBundle/Model/Note.php | 0 src/AppBundle/Model/Session.php | 0 src/AppBundle/Model/User.php | 0 structure.sql | 0 tests/BaseTestCase.php | 0 tests/Model/ChangeTest.php | 50 ++++++++++++++++-- tests/Model/NoteTest.php | 0 tests/setup.php | 0 var/SymfonyRequirements.php | 0 var/cache/.gitkeep | 0 var/logs/.gitkeep | 0 var/sessions/.gitkeep | 0 web/.htaccess | 0 web/app.php | 0 web/app_dev.php | 0 web/apple-touch-icon.png | Bin web/config.php | 0 web/favicon.ico | Bin web/robots.txt | 0 74 files changed, 46 insertions(+), 15 deletions(-) mode change 100644 => 100755 .gitignore mode change 100644 => 100755 README.md mode change 100644 => 100755 app/.htaccess mode change 100644 => 100755 app/AppCache.php mode change 100644 => 100755 app/AppKernel.php mode change 100644 => 100755 app/Resources/views/base.html.twig mode change 100644 => 100755 app/Resources/views/default/index.html.twig mode change 100644 => 100755 app/autoload.php mode change 100644 => 100755 app/config/config.yml mode change 100644 => 100755 app/config/config_dev.yml mode change 100644 => 100755 app/config/config_prod.yml mode change 100644 => 100755 app/config/config_test.yml mode change 100644 => 100755 app/config/parameters.yml.dist mode change 100644 => 100755 app/config/routing.yml mode change 100644 => 100755 app/config/routing_dev.yml mode change 100644 => 100755 app/config/security.yml mode change 100644 => 100755 app/config/services.yml mode change 100644 => 100755 cli-client/.config1/config.json mode change 100644 => 100755 cli-client/.config2/config.json mode change 100644 => 100755 cli-client/main.go mode change 100644 => 100755 cli-client/main.php mode change 100644 => 100755 cli-client/test_11111111111111111111111111111111/folder1/my_note1.md mode change 100644 => 100755 cli-client/test_11111111111111111111111111111111/folder2/my_note1.md mode change 100644 => 100755 cli-client/test_11111111111111111111111111111111/folder2/my_note2.md mode change 100644 => 100755 cli-client/test_11111111111111111111111111111111/folder2/sub/subnote.md mode change 100644 => 100755 cli-client/test_22222222222222222222222222222222/folder1/my_note1.md mode change 100644 => 100755 cli-client/test_22222222222222222222222222222222/folder2/my_note1.md mode change 100644 => 100755 cli-client/test_22222222222222222222222222222222/folder2/my_note2.md mode change 100644 => 100755 cli-client/test_22222222222222222222222222222222/folder2/sub/subnote.md mode change 100644 => 100755 composer.json mode change 100644 => 100755 composer.lock delete mode 100644 notes.sublime-project mode change 100644 => 100755 phpunit.xml.dist mode change 100644 => 100755 src/.htaccess mode change 100644 => 100755 src/AppBundle/AppBundle.php mode change 100644 => 100755 src/AppBundle/Controller/ApiController.php mode change 100644 => 100755 src/AppBundle/Controller/FoldersController.php mode change 100644 => 100755 src/AppBundle/Controller/NotesController.php mode change 100644 => 100755 src/AppBundle/Controller/SessionsController.php mode change 100644 => 100755 src/AppBundle/Controller/SynchronizerController.php mode change 100644 => 100755 src/AppBundle/Controller/UsersController.php mode change 100644 => 100755 src/AppBundle/Diff.php mode change 100644 => 100755 src/AppBundle/Eloquent.php mode change 100644 => 100755 src/AppBundle/Exception/AuthException.php mode change 100644 => 100755 src/AppBundle/Exception/BaseException.php mode change 100644 => 100755 src/AppBundle/Exception/ForbiddenException.php mode change 100644 => 100755 src/AppBundle/Exception/MethodNotAllowedException.php mode change 100644 => 100755 src/AppBundle/Exception/NotFoundException.php mode change 100644 => 100755 src/AppBundle/Exception/UnauthorizedException.php mode change 100644 => 100755 src/AppBundle/Exception/ValidationException.php mode change 100644 => 100755 src/AppBundle/Model/Action.php mode change 100644 => 100755 src/AppBundle/Model/BaseModel.php mode change 100644 => 100755 src/AppBundle/Model/Change.php mode change 100644 => 100755 src/AppBundle/Model/Folder.php mode change 100644 => 100755 src/AppBundle/Model/FolderItem.php mode change 100644 => 100755 src/AppBundle/Model/Note.php mode change 100644 => 100755 src/AppBundle/Model/Session.php mode change 100644 => 100755 src/AppBundle/Model/User.php mode change 100644 => 100755 structure.sql mode change 100644 => 100755 tests/BaseTestCase.php mode change 100644 => 100755 tests/Model/ChangeTest.php mode change 100644 => 100755 tests/Model/NoteTest.php mode change 100644 => 100755 tests/setup.php mode change 100644 => 100755 var/SymfonyRequirements.php mode change 100644 => 100755 var/cache/.gitkeep mode change 100644 => 100755 var/logs/.gitkeep mode change 100644 => 100755 var/sessions/.gitkeep mode change 100644 => 100755 web/.htaccess mode change 100644 => 100755 web/app.php mode change 100644 => 100755 web/app_dev.php mode change 100644 => 100755 web/apple-touch-icon.png mode change 100644 => 100755 web/config.php mode change 100644 => 100755 web/favicon.ico mode change 100644 => 100755 web/robots.txt 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