Skip to content

Commit 2c658c2

Browse files
committed
Revert "Remove tests for deprecated classes"
This reverts commit 953fad5.
1 parent 1aea33e commit 2c658c2

File tree

7 files changed

+171
-0
lines changed

7 files changed

+171
-0
lines changed
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Doctrine MongoDBBundle
5+
*
6+
* The code was originally distributed inside the Symfony framework.
7+
*
8+
* (c) Fabien Potencier <[email protected]>
9+
* (c) Doctrine Project
10+
*
11+
* For the full copyright and license information, please view the LICENSE
12+
* file that was distributed with this source code.
13+
*/
14+
15+
namespace Doctrine\Bundle\MongoDBBundle\Tests\Mapping\Driver;
16+
17+
use Doctrine\Common\Persistence\Mapping\Driver\FileDriver;
18+
19+
abstract class AbstractDriverTest extends \PHPUnit_Framework_TestCase
20+
{
21+
public function testFindMappingFile()
22+
{
23+
$driver = $this->getDriver(array(
24+
'foo' => 'MyNamespace\MyBundle\DocumentFoo',
25+
$this->getFixtureDir() => 'MyNamespace\MyBundle\Document',
26+
));
27+
28+
$locator = $this->getDriverLocator($driver);
29+
30+
$this->assertEquals(
31+
$this->getFixtureDir() . '/Foo' . $this->getFileExtension(),
32+
$locator->findMappingFile('MyNamespace\MyBundle\Document\Foo')
33+
);
34+
}
35+
36+
public function testFindMappingFileInSubnamespace()
37+
{
38+
$driver = $this->getDriver(array(
39+
$this->getFixtureDir() => 'MyNamespace\MyBundle\Document',
40+
));
41+
42+
$locator = $this->getDriverLocator($driver);
43+
44+
$this->assertEquals(
45+
$this->getFixtureDir() . '/Foo.Bar' . $this->getFileExtension(),
46+
$locator->findMappingFile('MyNamespace\MyBundle\Document\Foo\Bar')
47+
);
48+
}
49+
50+
/**
51+
* @expectedException Doctrine\Common\Persistence\Mapping\MappingException
52+
*/
53+
public function testFindMappingFileNamespacedFoundFileNotFound()
54+
{
55+
$driver = $this->getDriver(array(
56+
$this->getFixtureDir() => 'MyNamespace\MyBundle\Document',
57+
));
58+
59+
$locator = $this->getDriverLocator($driver);
60+
$locator->findMappingFile('MyNamespace\MyBundle\Document\Missing');
61+
}
62+
63+
/**
64+
* @expectedException Doctrine\Common\Persistence\Mapping\MappingException
65+
*/
66+
public function testFindMappingNamespaceNotFound()
67+
{
68+
$driver = $this->getDriver(array(
69+
$this->getFixtureDir() => 'MyNamespace\MyBundle\Document',
70+
));
71+
72+
$locator = $this->getDriverLocator($driver);
73+
$locator->findMappingFile('MyOtherNamespace\MyBundle\Document\Foo');
74+
}
75+
76+
abstract protected function getFileExtension();
77+
abstract protected function getFixtureDir();
78+
abstract protected function getDriver(array $paths = array());
79+
80+
private function getDriverLocator(FileDriver $driver)
81+
{
82+
$ref = new \ReflectionProperty($driver, 'locator');
83+
$ref->setAccessible(true);
84+
85+
return $ref->getValue($driver);
86+
}
87+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<doctrine-mongo-mapping xmlns="http://doctrine-project.org/schemas/odm/doctrine-mongo-mapping"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://doctrine-project.org/schemas/odm/doctrine-mongo-mapping
5+
http://doctrine-project.org/schemas/odm/doctrine-mongo-mapping.xsd">
6+
7+
</doctrine-mongo-mapping>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<doctrine-mongo-mapping xmlns="http://doctrine-project.org/schemas/odm/doctrine-mongo-mapping"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://doctrine-project.org/schemas/odm/doctrine-mongo-mapping
5+
http://doctrine-project.org/schemas/odm/doctrine-mongo-mapping.xsd">
6+
7+
</doctrine-mongo-mapping>

Tests/Mapping/Driver/Fixtures/yml/Foo.Bar.mongodb.yml

Whitespace-only changes.

Tests/Mapping/Driver/Fixtures/yml/Foo.mongodb.yml

Whitespace-only changes.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Doctrine MongoDBBundle
5+
*
6+
* The code was originally distributed inside the Symfony framework.
7+
*
8+
* (c) Fabien Potencier <[email protected]>
9+
* (c) Doctrine Project
10+
*
11+
* For the full copyright and license information, please view the LICENSE
12+
* file that was distributed with this source code.
13+
*/
14+
15+
namespace Doctrine\Bundle\MongoDBBundle\Tests\Mapping\Driver;
16+
17+
use Doctrine\Bundle\MongoDBBundle\Mapping\Driver\XmlDriver;
18+
19+
class XmlDriverTest extends AbstractDriverTest
20+
{
21+
protected function getFileExtension()
22+
{
23+
return '.mongodb.xml';
24+
}
25+
26+
protected function getFixtureDir()
27+
{
28+
return __DIR__ . '/Fixtures/xml';
29+
}
30+
31+
protected function getDriver(array $prefixes = array())
32+
{
33+
return new XmlDriver($prefixes, $this->getFileExtension());
34+
}
35+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Doctrine MongoDBBundle
5+
*
6+
* The code was originally distributed inside the Symfony framework.
7+
*
8+
* (c) Fabien Potencier <[email protected]>
9+
* (c) Doctrine Project
10+
*
11+
* For the full copyright and license information, please view the LICENSE
12+
* file that was distributed with this source code.
13+
*/
14+
15+
namespace Doctrine\Bundle\MongoDBBundle\Tests\Mapping\Driver;
16+
17+
use Doctrine\Bundle\MongoDBBundle\Mapping\Driver\YamlDriver;
18+
19+
class YamlDriverTest extends AbstractDriverTest
20+
{
21+
protected function getFileExtension()
22+
{
23+
return '.mongodb.yml';
24+
}
25+
26+
protected function getFixtureDir()
27+
{
28+
return __DIR__ . '/Fixtures/yml';
29+
}
30+
31+
protected function getDriver(array $prefixes = array())
32+
{
33+
return new YamlDriver($prefixes, $this->getFileExtension());
34+
}
35+
}

0 commit comments

Comments
 (0)