Skip to content

Commit

Permalink
Fake merge tests are hard to do
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobemerick committed Feb 26, 2016
1 parent 5f2e885 commit 7fe4081
Showing 1 changed file with 50 additions and 1 deletion.
51 changes: 50 additions & 1 deletion tests/unit/Domain/Blog/Tag/MysqlTagRepositoryTest.php
Expand Up @@ -155,9 +155,11 @@ public function testGetTagCloud()
$testPostData = [
[
'id' => rand(1, 100),
'display' => 1,
],
[
'id' => rand(101, 200),
'display' => 1,
],
];

Expand Down Expand Up @@ -192,7 +194,54 @@ public function testGetTagCloud()
array_walk($testPTLinkData, [$this, 'insertPTLinkData']);
array_walk($testTagData, [$this, 'insertTagData']);

// todo assert stuff, I guess
$repository = new MysqlTagRepository(self::$connection);
$data = $repository->getTagCloud();

$this->assertNotFalse($data);
$this->assertInternalType('array', $data);

$tagCountData = array_map(function ($row) use ($testTagData) {
$tag = $row['tag_id'];
$tag = array_filter($testTagData, function ($row) use ($tag) {
return ($tag == $row['id']);
});
$tag = current($tag)['tag'];
return $tag;
}, $testPTLinkData);

$testCountData = [];
foreach ($tagCountData as $tagCountRow) {
$incremented = false;
foreach ($testCountData as $key => $testCountRow) {
if ($tagCountRow == $testCountRow['tag']) {
$testCountData[$key]['count']++;
$incremented = true;
break;
}
}
if (!$incremented) {
array_push($testCountData, [
'count' => 1,
'tag' => $tagCountRow,
]);
}
}

$this->assertCount(count($testCountData), $data);

usort($testCountData, function ($rowA, $rowB) {
return ($rowA['tag'] > $rowB['tag']);
});
usort($data, function ($rowA, $rowB) {
return ($rowA['tag'] > $rowB['tag']);
});

foreach ($testCountData as $key => $testCountRow) {
$this->assertArrayHasKey('count', $data[$key]);
$this->assertEquals($testCountRow['count'], $data[$key]['count']);
$this->assertArrayHasKey('tag', $data[$key]);
$this->assertEquals($testCountRow['tag'], $data[$key]['tag']);
}
}

public function testGetTagCloudInactive() {}
Expand Down

0 comments on commit 7fe4081

Please sign in to comment.