Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

MàJ tests

  • Loading branch information...
commit 2c86234f8caa1ec358a76eaa28a9d377c43ae196 1 parent 5503fc6
@bakura10 bakura10 authored
View
3  src/ZfrForum/Entity/Thread.php
@@ -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")}
* )
View
1  tests/ZfrForumTest/Fixture/ThreadFixture.php
@@ -69,6 +69,7 @@ function load(ObjectManager $manager)
$thread->addPost($post);
$manager->persist($thread);
+ $this->setReference("thread-$i", $thread);
}
$manager->flush();
View
15 tests/ZfrForumTest/Repository/PostRepositoryTest.php
@@ -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();
@@ -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();
@@ -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());
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.