Skip to content

Commit c307f98

Browse files
committed
Merge pull request #146 from WouterJ/phpcr_clean_tests
Clean up tests
2 parents 148d88f + 5573dcd commit c307f98

File tree

2 files changed

+7
-40
lines changed

2 files changed

+7
-40
lines changed

Tests/Unit/Doctrine/Phpcr/ContentRepositoryTest.php

Lines changed: 6 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,19 @@ class ContentRepositoryTest extends \PHPUnit_Framework_Testcase
1414

1515
public function setUp()
1616
{
17-
$this->document = $this->getMock('Symfony\Cmf\Bundle\RoutingBundle\Tests\Doctrine\Phpcr\TestDocument');
18-
$this->document2 = $this->getMock('Symfony\Cmf\Bundle\RoutingBundle\Tests\Doctrine\Phpcr\TestDocument');
17+
$this->document = new \stdClass;
18+
$this->document2 = new \stdClass;
1919
$this->objectManager = $this->getMock('Doctrine\Common\Persistence\ObjectManager');
2020
$this->objectManager2 = $this->getMock('Doctrine\Common\Persistence\ObjectManager');
2121
$this->managerRegistry = $this->getMock('Doctrine\Common\Persistence\ManagerRegistry');
2222
}
2323

2424
public function testFindById()
2525
{
26-
$this->document
27-
->expects($this->any())
28-
->method('getPath')
29-
->will($this->returnValue('/cms/my-document'))
30-
;
31-
3226
$this->objectManager
3327
->expects($this->any())
3428
->method('find')
29+
->with(null, 'id-123')
3530
->will($this->returnValue($this->document))
3631
;
3732

@@ -44,10 +39,7 @@ public function testFindById()
4439
$contentRepository = new ContentRepository($this->managerRegistry);
4540
$contentRepository->setManagerName('default');
4641

47-
$foundDocument = $contentRepository->findById('id-123');
48-
49-
$this->assertInstanceOf('Symfony\Cmf\Bundle\RoutingBundle\Tests\Doctrine\Phpcr\TestDocument', $foundDocument);
50-
$this->assertEquals('/cms/my-document', $foundDocument->getPath());
42+
$this->assertSame($this->document, $contentRepository->findById('id-123'));
5143
}
5244

5345
public function testGetContentId()
@@ -61,18 +53,6 @@ public function testGetContentId()
6153
*/
6254
public function testChangingDocumentManager()
6355
{
64-
$this->document
65-
->expects($this->any())
66-
->method('getPath')
67-
->will($this->returnValue('/cms/my-document'))
68-
;
69-
70-
$this->document2
71-
->expects($this->any())
72-
->method('getPath')
73-
->will($this->returnValue('/cms/new-document'))
74-
;
75-
7656
$this->objectManager
7757
->expects($this->any())
7858
->method('find')
@@ -105,23 +85,9 @@ function ($name) use ($objectManagers) {
10585
$contentRepository = new ContentRepository($this->managerRegistry);
10686

10787
$contentRepository->setManagerName('default');
108-
$foundDocument = $contentRepository->findById('id-123');
109-
$this->assertInstanceOf('Symfony\Cmf\Bundle\RoutingBundle\Tests\Doctrine\Phpcr\TestDocument', $foundDocument);
110-
$this->assertEquals('/cms/my-document', $foundDocument->getPath());
88+
$this->assertSame($this->document, $contentRepository->findById('id-123'));
11189

11290
$contentRepository->setManagerName('new_manager');
113-
$newFoundDocument = $contentRepository->findById('id-123');
114-
$this->assertInstanceOf('Symfony\Cmf\Bundle\RoutingBundle\Tests\Doctrine\Phpcr\TestDocument', $newFoundDocument);
115-
$this->assertEquals('/cms/new-document', $newFoundDocument->getPath());
116-
}
117-
}
118-
119-
/**
120-
* Empty Document class for use with getMock()
121-
*/
122-
class TestDocument
123-
{
124-
public function getPath()
125-
{
91+
$this->assertSame($this->document2, $contentRepository->findById('id-123'));
12692
}
12793
}

Tests/Unit/Doctrine/Phpcr/LocaleListenerTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public function setUp()
2121
$this->routeMock = $this->buildMock('Symfony\Cmf\Bundle\RoutingBundle\Doctrine\Phpcr\Route');
2222
$this->dmMock = $this->buildMock('Doctrine\ODM\PHPCR\DocumentManager');
2323
}
24+
2425
public function testMoved()
2526
{
2627
$moveArgs = new MoveEventArgs(

0 commit comments

Comments
 (0)