Completed
Push — master ( d11b01...1c170b )
by Daniel
17:01 queued 13:33
created

ScalarTest::testIntegerCollection()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 10

Duplication

Lines 14
Ratio 100 %

Importance

Changes 0
Metric Value
dl 14
loc 14
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 10
nc 1
nop 0
1
<?php
2
3
namespace Psi\Bridge\ContentType\Doctrine\PhpcrOdm\Tests\Functional;
4
5
use Psi\Bridge\ContentType\Doctrine\PhpcrOdm\Tests\Functional\Example\Article;
6
7
class ScalarTest extends PhpcrOdmTestCase
8
{
9 View Code Duplication
    public function setUp()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
10
    {
11
        $container = $this->getContainer([
12
            'mapping' => [
13
                Article::class => [
14
                    'fields' => [
15
                        'paragraphs' => [
16
                            'type' => 'collection',
17
                            'options' => [
18
                                'field' => 'text',
19
                                'field_options' => [],
20
                            ],
21
                        ],
22
                        'numbers' => [
23
                            'type' => 'collection',
24
                            'options' => [
25
                                'field' => 'integer',
26
                            ],
27
                        ],
28
                    ],
29
                ],
30
            ],
31
        ]);
32
        $this->documentManager = $container->get('doctrine_phpcr.document_manager');
0 ignored issues
show
Bug introduced by
The property documentManager does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
33
        $this->initPhpcr($this->documentManager);
34
    }
35
36 View Code Duplication
    public function testStringCollection()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
37
    {
38
        $article = new Article();
39
        $article->id = '/test/article';
40
        $article->title = 'Foo';
41
        $article->paragraphs = ['one', 'two', 'three'];
42
43
        $this->documentManager->persist($article);
44
        $this->documentManager->flush();
45
        $this->documentManager->clear();
46
47
        $article = $this->documentManager->find(null, '/test/article');
48
        $this->assertSame(['one', 'two', 'three'], $article->paragraphs);
49
    }
50
51 View Code Duplication
    public function testIntegerCollection()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
52
    {
53
        $article = new Article();
54
        $article->id = '/test/article';
55
        $article->title = 'Foo';
56
        $article->numbers = ['12', '13', '14'];
57
58
        $this->documentManager->persist($article);
59
        $this->documentManager->flush();
60
        $this->documentManager->clear();
61
62
        $article = $this->documentManager->find(null, '/test/article');
63
        $this->assertSame([12, 13, 14], $article->numbers);
64
    }
65
}
66