Skip to content

Commit

Permalink
MàJ tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bakura10 committed Oct 30, 2012
1 parent 5503fc6 commit 2c86234
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
3 changes: 2 additions & 1 deletion src/ZfrForum/Entity/Thread.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,9 @@ class Thread

/**
* @var Collection
* TODO: remettre UserInterface
*
* @ORM\ManyToMany(targetEntity="ZfrForum\Entity\UserInterface", fetch="EXTRA_LAZY")
* @ORM\ManyToMany(targetEntity="ZfrForum\Entity\User", fetch="EXTRA_LAZY")
* @ORM\JoinTable(name="ThreadsFollowers",
* inverseJoinColumns={@ORM\JoinColumn(name="user_id", referencedColumnName="id")}
* )
Expand Down
1 change: 1 addition & 0 deletions tests/ZfrForumTest/Fixture/ThreadFixture.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ function load(ObjectManager $manager)
$thread->addPost($post);

$manager->persist($thread);
$this->setReference("thread-$i", $thread);
}

$manager->flush();
Expand Down
15 changes: 6 additions & 9 deletions tests/ZfrForumTest/Repository/PostRepositoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public function tearDown()
public function testCanReportAPost()
{
$repository = $this->executor->getReferenceRepository();
$post = $repository->getReference('post-0');
$post = $repository->getReference('thread-0')->getLastPost();
$reportedBy = $repository->getReference('user-1');

$report = new Report();
Expand Down Expand Up @@ -106,10 +106,10 @@ public function testCanReportAPost()
$this->assertEquals(2, $reports->getTotalItemCount());
}

public function testAssertThatTheSameUserCannotReportTheSamePostTwice()
public function testThrowExceptionWhenTheSameUserReportTheSamePostTwice()
{
$repository = $this->executor->getReferenceRepository();
$post = $repository->getReference('post-0');
$post = $repository->getReference('thread-0')->getLastPost();
$reportedBy = $repository->getReference('user-1');

$report = new Report();
Expand All @@ -129,18 +129,15 @@ public function testAssertThatTheSameUserCannotReportTheSamePostTwice()
$this->assertEquals(1, $reports->getTotalItemCount());


// Let's add another report
// Let's try to add another report (of course, this is handled at a higher level in
// the service)
$report = new Report();
$report->setPost($post)
->setDescription('This post is REALLY a spam !')
->setReportedBy($reportedBy)
->setReportedAt(new DateTime('now'));

$this->setExpectedException('Doctrine\DBAL\DBALException');
$this->reportMapper->create($report);

$reports = $this->reportMapper->findByPost($post);

$this->assertInstanceOf('Zend\Paginator\Paginator', $reports);
$this->assertEquals(1, $reports->getTotalItemCount());
}
}

0 comments on commit 2c86234

Please sign in to comment.