Removed IDs from tags.json

This commit is contained in:
Marcin Kurczewski 2014-10-15 15:58:48 +02:00
parent 0d50550c43
commit 850e496215
2 changed files with 6 additions and 4 deletions

View file

@ -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);

View file

@ -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()