From 850e496215613167eccc60ae07005637a387e49d Mon Sep 17 00:00:00 2001 From: Marcin Kurczewski Date: Wed, 15 Oct 2014 15:58:48 +0200 Subject: [PATCH] Removed IDs from tags.json --- src/Services/TagService.php | 6 ++++-- tests/Services/TagServiceTest.php | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Services/TagService.php b/src/Services/TagService.php index 4c630a80..16ffa45f 100644 --- a/src/Services/TagService.php +++ b/src/Services/TagService.php @@ -73,10 +73,12 @@ class TagService $tags = []; foreach ($this->tagDao->findAll() as $tag) { - $tags[$tag->getId()] = [ + $item = [ 'name' => $tag->getName(), 'usages' => $tag->getUsages(), - 'banned' => $tag->isBanned()]; + 'banned' => $tag->isBanned(), + ]; + $tags[] = $item; } $json = json_encode($tags); $this->fileDao->save('tags.json', $json); diff --git a/tests/Services/TagServiceTest.php b/tests/Services/TagServiceTest.php index 343bbc1d..55faa1ce 100644 --- a/tests/Services/TagServiceTest.php +++ b/tests/Services/TagServiceTest.php @@ -78,7 +78,7 @@ final class TagServiceTest extends AbstractDatabaseTestCase $tagService = $this->getTagService(); $tagService->createTags([$tag1]); $tagService->exportJson(); - $this->assertEquals('{"1":{"name":"test","usages":0,"banned":false}}', $fileDao->load('tags.json')); + $this->assertEquals('[{"name":"test","usages":0,"banned":false}]', $fileDao->load('tags.json')); } public function testExportMultiple() @@ -94,7 +94,7 @@ final class TagServiceTest extends AbstractDatabaseTestCase $tagService = $this->getTagService(); $tagService->createTags([$tag1, $tag2]); $tagService->exportJson(); - $this->assertEquals('{"1":{"name":"test1","usages":0,"banned":false},"2":{"name":"test2","usages":0,"banned":true}}', $fileDao->load('tags.json')); + $this->assertEquals('[{"name":"test1","usages":0,"banned":false},{"name":"test2","usages":0,"banned":true}]', $fileDao->load('tags.json')); } private function getPublicFileDao()