forked from doctrine-extensions/DoctrineExtensions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SoftDeleteableMappingTest.php
67 lines (55 loc) · 2.05 KB
/
SoftDeleteableMappingTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?php
namespace Gedmo\Mapping;
use Doctrine\Common\Annotations\AnnotationReader;
use Doctrine\ORM\Mapping\Driver\AnnotationDriver;
use Doctrine\Common\EventManager;
use Doctrine\ORM\Mapping\Driver\DriverChain;
use Doctrine\ORM\Mapping\Driver\YamlDriver;
use Gedmo\SoftDeleteable\SoftDeleteableListener;
use Tool\BaseTestCaseOM;
/**
* These are mapping tests for SoftDeleteable extension
*
* @author Gustavo Falco <comfortablynumb84@gmail.com>
* @author Gediminas Morkevicius <gediminas.morkevicius@gmail.com>
* @package Gedmo.Mapping
* @link http://www.gediminasm.org
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
class SoftDeleteableMappingTest extends BaseTestCaseOM
{
/**
* @var Doctrine\ORM\EntityManager
*/
private $em;
/**
* @var Gedmo\SoftDeleteable\SoftDeleteableListener
*/
private $softDeleteable;
public function setUp()
{
parent::setUp();
$reader = new AnnotationReader();
$annotationDriver = new AnnotationDriver($reader);
$yamlDriver = new YamlDriver(__DIR__.'/Driver/Yaml');
$chain = new DriverChain;
$chain->addDriver($yamlDriver, 'Mapping\Fixture\Yaml');
$chain->addDriver($annotationDriver, 'Mapping\Fixture');
$this->softDeleteable = new SoftDeleteableListener();
$this->evm = new EventManager;
$this->evm->addEventSubscriber($this->softDeleteable);
$this->em = $this->getMockSqliteEntityManager(array(
'Mapping\Fixture\Yaml\SoftDeleteable',
'Mapping\Fixture\SoftDeleteable'
), $chain);
}
public function testYamlMapping()
{
$meta = $this->em->getClassMetadata('Mapping\Fixture\Yaml\SoftDeleteable');
$config = $this->softDeleteable->getConfiguration($this->em, $meta->name);
$this->assertArrayHasKey('softDeleteable', $config);
$this->assertTrue($config['softDeleteable']);
$this->assertArrayHasKey('fieldName', $config);
$this->assertEquals('deletedAt', $config['fieldName']);
}
}