Completed
Pull Request — master (#42)
by Daniel
08:48
created

DoctrineBenchTrait::getContainer()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 46
Code Lines 29

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 46
rs 8.9411
c 0
b 0
f 0
cc 1
eloc 29
nc 1
nop 1
1
<?php
2
3
namespace Psi\Component\ContentType\Benchmark;
4
5
use Psi\Component\ContentType\Tests\Functional\Example\Model\Article;
6
use Psi\Component\ContentType\Tests\Functional\Example\Model\Image;
7
8
/**
9
 * @BeforeMethods({"setUp"})
10
 * @Revs(1)
11
 * @Iterations(10)
12
 * @OutputTimeUnit("milliseconds", precision=2)
13
 */
14
trait DoctrineBenchTrait
15
{
16
    protected $objectManager;
17
18
    public function getContainer(array $config = [])
0 ignored issues
show
Unused Code introduced by
The parameter $config is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
19
    {
20
        $container = parent::getContainer([
21
            'mapping' => [
22
                Article::class => [
23
                    'properties' => [
24
                        'title' => [
25
                            'type' => 'text',
26
                            'role' => 'title',
27
                        ],
28
                        'image' => [
29
                            'type' => 'image',
30
                            'role' => 'image',
31
                        ],
32
                        'slideshow' => [
33
                            'type' => 'collection',
34
                            'options' => [
35
                                'field_type' => 'image',
36
                            ],
37
                        ],
38
                        'date' => [
39
                            'type' => 'datetime',
40
                        ],
41
                        'referencedImage' => [
42
                            'type' => 'object_reference',
43
                        ],
44
                        'paragraphs' => [
45
                            'type' => 'collection',
46
                            'options' => [
47
                                'field_type' => 'text',
48
                                'field_options' => [],
49
                            ],
50
                        ],
51
                        'numbers' => [
52
                            'type' => 'collection',
53
                            'options' => [
54
                                'field_type' => 'integer',
55
                            ],
56
                        ],
57
                    ],
58
                ],
59
            ],
60
        ]);
61
62
        return $container;
63
    }
64
65
    /**
66
     * @Subject()
67
     */
68
    public function image_phpcr_odm_only()
69
    {
70
        static $id;
71
        $image = new Image(
72
            '/path/to/image', 100, 200, 'image/jpeg'
73
        );
74
        $image->id = '/test/image' . $id++;
75
76
        $this->objectManager->persist($image);
77
        $this->objectManager->flush();
78
    }
79
80
    /**
81
     * @Subject()
82
     */
83
    public function ct_article()
84
    {
85
        static $id;
86
        $article = new Article();
87
        $article->id = '/test/article' . $id++;
88
        $article->title = 'Hello';
89
        $article->date = new \DateTime('2016-01-01 00:00:00');
90
91
        $this->objectManager->persist($article);
92
        $this->objectManager->flush();
93
    }
94
95
    /**
96
     * @Subject()
97
     */
98
    public function ct_article_with_image()
99
    {
100
        static $id;
101
        $article = new Article();
102
        $article->id = '/test/article' . $id++;
103
        $article->title = 'Hello';
104
        $article->date = new \DateTime('2016-01-01 00:00:00');
105
106
        $article->image = new Image(
107
            '/path/to/image', 100, 200, 'image/jpeg'
108
        );
109
110
        $this->objectManager->persist($article);
111
        $this->objectManager->flush();
112
    }
113
}
114