Skip to content

Commit

Permalink
fixes for scrutinizer-ci initial run
Browse files Browse the repository at this point in the history
  • Loading branch information
reecefowell committed Dec 19, 2013
1 parent 9679561 commit 734eea0
Show file tree
Hide file tree
Showing 14 changed files with 61 additions and 66 deletions.
2 changes: 1 addition & 1 deletion Component/Helper/RoleHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public function getUsersHighestRole($usersRoles)

// Compare (A)vailable roles against (U)sers roles.
foreach ($this->availableRoleKeys as $aRoleKey => $aRole) {
foreach ($usersRoles as $uRoleKey => $uRole) {
foreach ($usersRoles as $uRole) {
if ($uRole == $aRole && $aRoleKey > $usersHighestRoleKey) {
$usersHighestRoleKey = $aRoleKey;

Expand Down
3 changes: 1 addition & 2 deletions Controller/ModeratorPostBaseController.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,10 @@ class ModeratorPostBaseController extends BaseController
/**
*
* @access protected
* @param \CCDNForum\ForumBundle\Entity\Forum $forum
* @param \CCDNForum\ForumBundle\Entity\Post $post
* @return \CCDNForum\ForumBundle\Form\Handler\Moderator\Post\PostUnlockFormHandler
*/
protected function getFormHandlerToUnlockPost(Forum $forum, Post $post)
protected function getFormHandlerToUnlockPost(Post $post)
{
$formHandler = $this->container->get('ccdn_forum_forum.form.handler.post_unlock');

Expand Down
4 changes: 2 additions & 2 deletions Controller/ModeratorPostController.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function unlockAction($forumName, $postId)
$this->isFound($forum = $this->getForumModel()->findOneForumByName($forumName));
$this->isFound($post = $this->getPostModel()->findOnePostByIdWithTopicAndBoard($postId, true));
$this->isAuthorised($this->getAuthorizer()->canUnlockPost($post, $forum));
$formHandler = $this->getFormHandlerToUnlockPost($forum, $post);
$formHandler = $this->getFormHandlerToUnlockPost($post);
$response = $this->renderResponse('CCDNForumForumBundle:Moderator:Post/unlock.html.', array(
'crumbs' => $this->getCrumbs()->addModeratorPostUnlock($forum, $post),
'forum' => $forum,
Expand All @@ -95,7 +95,7 @@ public function unlockProcessAction($forumName, $postId)
$this->isFound($forum = $this->getForumModel()->findOneForumByName($forumName));
$this->isFound($post = $this->getPostModel()->findOnePostByIdWithTopicAndBoard($postId, true));
$this->isAuthorised($this->getAuthorizer()->canUnlockPost($post, $forum));
$formHandler = $this->getFormHandlerToUnlockPost($forum, $post);
$formHandler = $this->getFormHandlerToUnlockPost($post);

if ($formHandler->process()) {
$response = $this->redirectResponseForTopicOnPageFromPost($forumName, $post->getTopic(), $post);
Expand Down
3 changes: 1 addition & 2 deletions Controller/ModeratorTopicBaseController.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,10 @@ class ModeratorTopicBaseController extends BaseController
/**
*
* @access protected
* @param \CCDNForum\ForumBundle\Entity\Forum $forum
* @param \CCDNForum\ForumBundle\Entity\Topic $topic
* @return \CCDNForum\ForumBundle\Form\Handler\TopicCreateFormHandler
*/
protected function getFormHandlerToDeleteTopic(Forum $forum, Topic $topic)
protected function getFormHandlerToDeleteTopic(Topic $topic)
{
$formHandler = $this->container->get('ccdn_forum_forum.form.handler.topic_delete');

Expand Down
4 changes: 2 additions & 2 deletions Controller/ModeratorTopicController.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public function deleteAction($forumName, $topicId)
$this->isFound($forum = $this->getForumModel()->findOneForumByName($forumName));
$this->isFound($topic = $this->getTopicModel()->findOneTopicByIdWithBoardAndCategory($topicId, true));
$this->isAuthorised($this->getAuthorizer()->canDeleteTopic($topic, $forum));
$formHandler = $this->getFormHandlerToDeleteTopic($forum, $topic);
$formHandler = $this->getFormHandlerToDeleteTopic($topic);
$response = $this->renderResponse('CCDNForumForumBundle:Moderator:Topic/delete.html.', array(
'crumbs' => $this->getCrumbs()->addModeratorTopicDelete($forum, $topic),
'forum' => $forum,
Expand All @@ -161,7 +161,7 @@ public function deleteProcessAction($forumName, $topicId)
$this->isFound($forum = $this->getForumModel()->findOneForumByName($forumName));
$this->isFound($topic = $this->getTopicModel()->findOneTopicByIdWithBoardAndCategory($topicId, true));
$this->isAuthorised($this->getAuthorizer()->canDeleteTopic($topic, $forum));
$formHandler = $this->getFormHandlerToDeleteTopic($forum, $topic);
$formHandler = $this->getFormHandlerToDeleteTopic($topic);

if ($formHandler->process()) {
$response = $this->redirectResponseForTopicOnPageFromPost($forumName, $topic, $topic->getLastPost());
Expand Down
26 changes: 13 additions & 13 deletions Tests/Manager/SubscriptionManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function testSubscribe()
$categories = $this->addFixturesForCategories($forums);
$boards = $this->addFixturesForBoards($categories);
$topics = $this->addFixturesForTopics($boards);
$posts = $this->addFixturesForPosts($topics, $users['tom']);
$this->addFixturesForPosts($topics, $users['tom']);
$this->getSubscriptionModel()->subscribe($topics[0], $users['tom']);
$subscriptionFound = $this->getSubscriptionModel()->findOneSubscriptionForTopicByIdAndUserById($topics[0]->getId(), $users['tom']->getId());

Expand All @@ -42,7 +42,7 @@ public function testUnsubscribe()
$categories = $this->addFixturesForCategories($forums);
$boards = $this->addFixturesForBoards($categories);
$topics = $this->addFixturesForTopics($boards);
$posts = $this->addFixturesForPosts($topics, $users['tom']);
$this->addFixturesForPosts($topics, $users['tom']);
$this->getSubscriptionModel()->subscribe($topics[0], $users['tom']);
$this->getSubscriptionModel()->unsubscribe($topics[0], $users['tom']->getId());
$subscriptionFound = $this->getSubscriptionModel()->findOneSubscriptionForTopicByIdAndUserById($topics[0]->getId(), $users['tom']->getId());
Expand All @@ -59,17 +59,17 @@ public function testMarkAsRead()
$categories = $this->addFixturesForCategories($forums);
$boards = $this->addFixturesForBoards($categories);
$topics = $this->addFixturesForTopics($boards);
$posts = $this->addFixturesForPosts($topics, $users['tom']);
$this->addFixturesForPosts($topics, $users['tom']);
$this->getSubscriptionModel()->subscribe($topics[0], $users['tom']);
$subscriptionFound = $this->getSubscriptionModel()->findOneSubscriptionForTopicByIdAndUserById($topics[0]->getId(), $users['tom']->getId());
$this->getSubscriptionModel()->markAsRead($subscriptionFound);
$subscriptionsFound = $this->getSubscriptionModel()->findAllSubscriptionsForUserById($users['tom']->getId(), true);

foreach ($subscriptionsFound as $subscription) {
if ($subscriptionFound->getTopic()->getId() == $topics[0]->getId()) {
$this->assertTrue($subscriptionFound->isSubscribed());
$this->assertTrue($subscriptionFound->isRead());
$this->assertInternalType('integer', $subscriptionFound->getId());
if ($subscription->getTopic()->getId() == $topics[0]->getId()) {
$this->assertTrue($subscription->isSubscribed());
$this->assertTrue($subscription->isRead());
$this->assertInternalType('integer', $subscription->getId());
}
}
}
Expand All @@ -82,17 +82,17 @@ public function testMarkAsUnread()
$categories = $this->addFixturesForCategories($forums);
$boards = $this->addFixturesForBoards($categories);
$topics = $this->addFixturesForTopics($boards);
$posts = $this->addFixturesForPosts($topics, $users['tom']);
$this->addFixturesForPosts($topics, $users['tom']);
$this->getSubscriptionModel()->subscribe($topics[0], $users['tom']);
$subscriptionFound = $this->getSubscriptionModel()->findOneSubscriptionForTopicByIdAndUserById($topics[0]->getId(), $users['tom']->getId());
$this->getSubscriptionModel()->markAsUnread($subscriptionFound);
$subscriptionsFound = $this->getSubscriptionModel()->findAllSubscriptionsForUserById($users['tom']->getId(), true);

foreach ($subscriptionsFound as $subscription) {
if ($subscriptionFound->getTopic()->getId() == $topics[0]->getId()) {
$this->assertTrue($subscriptionFound->isSubscribed());
$this->assertFalse($subscriptionFound->isRead());
$this->assertInternalType('integer', $subscriptionFound->getId());
if ($subscription->getTopic()->getId() == $topics[0]->getId()) {
$this->assertTrue($subscription->isSubscribed());
$this->assertFalse($subscription->isRead());
$this->assertInternalType('integer', $subscription->getId());
}
}
}
Expand All @@ -105,7 +105,7 @@ public function testMarkTheseAsUnread()
$categories = $this->addFixturesForCategories($forums);
$boards = $this->addFixturesForBoards($categories);
$topics = $this->addFixturesForTopics($boards);
$posts = $this->addFixturesForPosts($topics, $users['tom']);
$this->addFixturesForPosts($topics, $users['tom']);
$this->getSubscriptionModel()->subscribe($topics[0], $users['tom']);
$this->getSubscriptionModel()->subscribe($topics[0], $users['dick']);
$this->getSubscriptionModel()->subscribe($topics[0], $users['harry']);
Expand Down
14 changes: 7 additions & 7 deletions Tests/Manager/TopicManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function testUpdateTopic()
$categories = $this->addFixturesForCategories($forums);
$boards = $this->addFixturesForBoards($categories);
$topics = $this->addFixturesForTopics($boards);
$posts = $this->addFixturesForPosts($topics, $users['tom']);
$this->addFixturesForPosts($topics, $users['tom']);
$topics[0]->setTitle('the_new_title');
$this->getTopicModel()->updateTopic($topics[0]);
$this->em->refresh($topics[0]);
Expand Down Expand Up @@ -73,7 +73,7 @@ public function testRestore()
$categories = $this->addFixturesForCategories($forums);
$boards = $this->addFixturesForBoards($categories);
$topics = $this->addFixturesForTopics($boards);
$posts = $this->addFixturesForPosts($topics, $users['tom']);
$this->addFixturesForPosts($topics, $users['tom']);
$this->getTopicModel()->softDelete($topics[0], $users['tom']);
$this->em->refresh($topics[0]);

Expand All @@ -91,7 +91,7 @@ public function testSoftDelete()
$categories = $this->addFixturesForCategories($forums);
$boards = $this->addFixturesForBoards($categories);
$topics = $this->addFixturesForTopics($boards);
$posts = $this->addFixturesForPosts($topics, $users['tom']);
$this->addFixturesForPosts($topics, $users['tom']);
$this->getTopicModel()->softDelete($topics[0], $users['tom']);
$this->em->refresh($topics[0]);

Expand All @@ -106,7 +106,7 @@ public function testSticky()
$categories = $this->addFixturesForCategories($forums);
$boards = $this->addFixturesForBoards($categories);
$topics = $this->addFixturesForTopics($boards);
$posts = $this->addFixturesForPosts($topics, $users['tom']);
$this->addFixturesForPosts($topics, $users['tom']);
$this->getTopicModel()->sticky($topics[0], $users['tom']);
$this->em->refresh($topics[0]);

Expand All @@ -121,7 +121,7 @@ public function testUnsticky()
$categories = $this->addFixturesForCategories($forums);
$boards = $this->addFixturesForBoards($categories);
$topics = $this->addFixturesForTopics($boards);
$posts = $this->addFixturesForPosts($topics, $users['tom']);
$this->addFixturesForPosts($topics, $users['tom']);
$this->getTopicModel()->unsticky($topics[0]);
$this->em->refresh($topics[0]);

Expand All @@ -136,7 +136,7 @@ public function testClose()
$categories = $this->addFixturesForCategories($forums);
$boards = $this->addFixturesForBoards($categories);
$topics = $this->addFixturesForTopics($boards);
$posts = $this->addFixturesForPosts($topics, $users['tom']);
$this->addFixturesForPosts($topics, $users['tom']);
$this->getTopicModel()->close($topics[0], $users['tom']);
$this->em->refresh($topics[0]);

Expand All @@ -151,7 +151,7 @@ public function testReopen()
$categories = $this->addFixturesForCategories($forums);
$boards = $this->addFixturesForBoards($categories);
$topics = $this->addFixturesForTopics($boards);
$posts = $this->addFixturesForPosts($topics, $users['tom']);
$this->addFixturesForPosts($topics, $users['tom']);
$this->getTopicModel()->reopen($topics[0]);
$this->em->refresh($topics[0]);

Expand Down
6 changes: 3 additions & 3 deletions Tests/Repository/BoardRepositoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function testFindAllBoards()
$this->purge();
$forums = $this->addFixturesForForums();
$categories = $this->addFixturesForCategories($forums);
$boards = $this->addFixturesForBoards($categories);
$this->addFixturesForBoards($categories);
$boardsFound = $this->getBoardModel()->findAllBoards();

// 3 Forums, with 3 categories each respectively, 3x3 = 9 Categories total.
Expand All @@ -49,7 +49,7 @@ public function testFindAllBoardsForForumById()
$this->purge();
$forum = $this->addNewForum('testFindAllBoardsForForumById');
$categories = $this->addFixturesForCategories(array($forum));
$boards = $this->addFixturesForBoards($categories);
$this->addFixturesForBoards($categories);
$foundBoards = $this->getBoardModel()->findAllBoardsForForumById($forum->getId());

$this->assertCount(9, $foundBoards);
Expand Down Expand Up @@ -84,7 +84,7 @@ public function testGetBoardCount()
$this->purge();
$forum = $this->addNewForum('TestForum');
$categories = $this->addFixturesForCategories(array($forum));
$boards = $this->addFixturesForBoards($categories);
$this->addFixturesForBoards($categories);
$count = $this->getBoardModel()->getBoardCount();

$this->assertSame(9, (int) $count);
Expand Down
6 changes: 3 additions & 3 deletions Tests/Repository/CategoryRepositoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function testFindAllCategories()
{
$this->purge();
$forum = $this->addFixturesForForums();
$category = $this->addFixturesForCategories($forum);
$this->addFixturesForCategories($forum);
$categoriesFound = $this->getCategoryModel()->findAllCategories();

// 3 Forums, with 3 categories each respectively, 3x3 = 9 Categories total.
Expand All @@ -32,7 +32,7 @@ public function testFindAllCategoriesForForumById()
{
$this->purge();
$forums = $this->addFixturesForForums();
$category = $this->addFixturesForCategories($forums);
$this->addFixturesForCategories($forums);

foreach ($forums as $forum) {
$categoriesFound = $this->getCategoryModel()->findAllCategoriesForForumById($forum->getId());
Expand All @@ -46,7 +46,7 @@ public function testFindAllCategoriesWithBoardsForForumByName()
$this->purge();
$forum = $this->addNewForum('testFindAllCategoriesWithBoardsForForumByName');
$categories = $this->addFixturesForCategories(array($forum));
$boards = $this->addFixturesForBoards($categories);
$this->addFixturesForBoards($categories);
$foundCategories = $this->getCategoryModel()->findAllCategoriesWithBoardsForForumByName($forum->getName());

$this->assertCount(3, $foundCategories);
Expand Down
14 changes: 7 additions & 7 deletions Tests/Repository/PostRepositoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function testGetFirstPostForTopicById()
$categories = $this->addFixturesForCategories($forums);
$boards = $this->addFixturesForBoards($categories);
$topics = $this->addFixturesForTopics($boards);
$posts = $this->addFixturesForPosts($topics, $users['tom']);
$this->addFixturesForPosts($topics, $users['tom']);
$firstPost = $this->getPostModel()->getFirstPostForTopicById($topics[0]->getId());

$this->assertSame($firstPost->getId(), $topics[0]->getFirstPost()->getId());
Expand All @@ -87,7 +87,7 @@ public function testGetLastPostForTopicById()
$categories = $this->addFixturesForCategories($forums);
$boards = $this->addFixturesForBoards($categories);
$topics = $this->addFixturesForTopics($boards);
$posts = $this->addFixturesForPosts($topics, $users['tom']);
$this->addFixturesForPosts($topics, $users['tom']);
$lastPost = $this->getPostModel()->getLastPostForTopicById($topics[0]->getId());

$this->assertSame($lastPost->getId(), $topics[0]->getLastPost()->getId());
Expand All @@ -101,23 +101,23 @@ public function testCountPostsForTopicById()
$categories = $this->addFixturesForCategories($forums);
$boards = $this->addFixturesForBoards($categories);
$topics = $this->addFixturesForTopics($boards);
$posts = $this->addFixturesForPosts($topics, $users['tom']);
$this->addFixturesForPosts($topics, $users['tom']);
$count = $this->getPostModel()->countPostsForTopicById($topics[0]->getId());

$this->assertSame(3, (int) $count);
}

public function countPostsForUserById($userId)
public function testCountPostsForUserById()
{
$this->purge();
$users = $this->addFixturesForUsers();
$forums = $this->addFixturesForForums();
$categories = $this->addFixturesForCategories($forums);
$boards = $this->addFixturesForBoards($categories);
$topics = $this->addFixturesForTopics($boards);
$posts = $this->addFixturesForPosts($topics, $users['tom']);
$this->addFixturesForPosts($topics, $users['tom']);
$count = $this->getPostModel()->countPostsForUserById($users['tom']->getId());
ldd($count);
$this->assertSame(3, (int) $count);

$this->assertSame(243, (int) $count);
}
}
Loading

0 comments on commit 734eea0

Please sign in to comment.