GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

PostManagerTest::testUpdatePost()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 16
Code Lines 13

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 16
rs 9.4285
cc 1
eloc 13
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of the CCDNForum ForumBundle
5
 *
6
 * (c) CCDN (c) CodeConsortium <http://www.codeconsortium.com/>
7
 *
8
 * Available on github <http://www.github.com/codeconsortium/>
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace CCDNForum\ForumBundle\Tests\Manager;
15
16
use Doctrine\Common\Collections\ArrayCollection;
17
use CCDNForum\ForumBundle\Tests\TestBase;
18
19
class PostManagerTest extends TestBase
20
{
21
	public function testSavePost()
22
	{
23
		$this->purge();
24
		$users = $this->addFixturesForUsers();
25
		$topic = $this->addNewTopic('NewTopicTest', null, false, false);
26
		$post = $this->addNewPost('foobar', $topic, $users['tom'], new \DateTime(), false, false);
27
		$this->getPostModel()->savePost($post);
28
		$this->em->refresh($post);
29
		$topic->setFirstPost($post);
30
		$topic->setLastPost($post);
31
		$this->getTopicModel()->saveTopic($topic);
32
		$post2 = $this->addNewPost('foobar', $topic, $users['tom'], new \DateTime(), false, false);
33
		$this->getPostModel()->savePost($post2);
34
		$foundTopic = $this->getTopicModel()->findOneTopicByIdWithBoardAndCategory($topic->getId(), true);
35
36
		$this->assertNotNull($foundTopic);
37
		$this->assertInstanceOf('CCDNForum\ForumBundle\Entity\Topic', $foundTopic);
38
		$this->assertTrue(is_numeric($foundTopic->getId()));
39
		$this->assertSame('NewTopicTest', $foundTopic->getTitle());
40
	}
41
42
    public function testUpdatePost()
43
    {
44
		$this->purge();
45
		$users = $this->addFixturesForUsers();
46
		$topic = $this->addNewTopic('NewTopicTest', null, false, false);;
47
		$post = $this->addNewPost('foobar', $topic, $users['tom'], new \DateTime(), false, false);
48
		$this->getPostModel()->savePost($post);
49
		$this->getTopicModel()->saveTopic($topic);
50
		$this->em->refresh($post);
51
		$post->setBody('edited post');
52
		$this->getPostModel()->updatePost($post);
53
		$this->em->refresh($post);
54
55
		$this->assertTrue(is_numeric($post->getId()));
56
		$this->assertSame('edited post', $post->getBody());
57
    }
58
	
59
	public function testSoftDeletePost()
60
	{
61
		$this->purge();
62
		$users = $this->addFixturesForUsers();
63
		$forums = $this->addFixturesForForums();
64
		$categories = $this->addFixturesForCategories($forums);
65
		$boards = $this->addFixturesForBoards($categories);
66
		$topics = $this->addFixturesForTopics($boards);
67
		$posts = $this->addFixturesForPosts($topics, $users['tom']);
68
		$this->getPostModel()->softDelete($posts[0], $users['tom']);
69
		$this->em->refresh($posts[0]);
70
		
71
		$this->assertTrue($posts[0]->isDeleted());
72
	}
73
74
	public function testRestorePost()
75
	{
76
		$this->purge();
77
		$users = $this->addFixturesForUsers();
78
		$forums = $this->addFixturesForForums();
79
		$categories = $this->addFixturesForCategories($forums);
80
		$boards = $this->addFixturesForBoards($categories);
81
		$topics = $this->addFixturesForTopics($boards);
82
		$posts = $this->addFixturesForPosts($topics, $users['tom']);
83
		$this->getPostModel()->softDelete($posts[0], $users['tom']);
84
		$this->em->refresh($posts[0]);
85
		$this->getPostModel()->restore($posts[0]);
86
		$this->em->refresh($posts[0]);
87
		
88
		$this->assertFalse($posts[0]->isDeleted());
89
	}
90
}