Completed
Pull Request — master (#395)
by
unknown
02:26
created

testDescribesCollectionValuedAssociationProvider()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 13
rs 9.4285
cc 1
eloc 10
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of the Sonata Project package.
5
 *
6
 * (c) Thomas Rabaix <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Sonata\DoctrinePHPCRAdminBundle\Tests\Admin;
13
14
use Doctrine\ODM\PHPCR\Mapping\ClassMetadata;
15
use Sonata\DoctrinePHPCRAdminBundle\Admin\FieldDescription;
16
17
class FieldDescriptionTest  extends \PHPUnit_Framework_TestCase
18
{
19
    /**
20
     * @dataProvider testDescribesSingleValuedAssociationProvider
21
     *
22
     * @param mixed $mappingType
23
     * @param bool  $expected
24
     */
25
    public function testDescribesSingleValuedAssociation($mappingType, $expected)
26
    {
27
        $fd = new FieldDescription();
28
        $fd->setAssociationMapping(array(
29
            'fieldName' => 'foo',
30
            'type' => $mappingType,
31
        ));
32
        $this->assertSame($expected, $fd->describesSingleValuedAssociation());
33
    }
34
35
    public function testDescribesSingleValuedAssociationProvider()
36
    {
37
        return array(
38
            'many to one' => array(ClassMetadata::MANY_TO_ONE, true),
39
            'parent' => array('parent', true),
40
            'child' => array('child', true),
41
            'many to many' => array(ClassMetadata::MANY_TO_MANY, false),
42
            'children' => array('children', false),
43
            'referrers' => array('referrers', false),
44
            'mixedreferrers' => array('mixedreferrers', false),
45
            'string' => array('string', false),
46
        );
47
    }
48
49
    /**
50
     * @dataProvider testDescribesCollectionValuedAssociationProvider
51
     *
52
     * @param mixed $mappingType
53
     * @param bool  $expected
54
     */
55
    public function testDescribesCollectionValuedAssociation($mappingType, $expected)
56
    {
57
        $fd = new FieldDescription();
58
        $fd->setAssociationMapping(array(
59
            'fieldName' => 'foo',
60
            'type' => $mappingType,
61
        ));
62
        $this->assertSame($expected, $fd->describesCollectionValuedAssociation());
63
    }
64
65
    public function testDescribesCollectionValuedAssociationProvider()
66
    {
67
        return array(
68
            'many to one' => array(ClassMetadata::MANY_TO_ONE, false),
69
            'parent' => array('parent', false),
70
            'child' => array('child', false),
71
            'many to many' => array(ClassMetadata::MANY_TO_MANY, true),
72
            'children' => array('children', true),
73
            'referrers' => array('referrers', true),
74
            'mixedreferrers' => array('mixedreferrers', true),
75
            'string' => array('string', false),
76
        );
77
    }
78
}
79