PhpcrOdmTestCase::createArticleSlideshow()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 17
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 17
rs 9.4285
cc 1
eloc 11
nc 1
nop 0
1
<?php
2
3
namespace Psi\Bridge\ContentType\Doctrine\PhpcrOdm\Tests\Functional;
4
5
use Doctrine\ODM\PHPCR\DocumentManagerInterface;
6
use Psi\Component\ContentType\Tests\Functional\Example\Model\Article;
7
use Psi\Component\ContentType\Tests\Functional\Example\Model\Image;
8
9
class PhpcrOdmTestCase extends \PHPUnit_Framework_TestCase
10
{
11
    protected function getContainer(array $config = [])
12
    {
13
        return new Container($config);
14
    }
15
16
    protected function initPhpcr(DocumentManagerInterface $documentManager)
17
    {
18
        $session = $documentManager->getPhpcrSession();
19
20
        $rootNode = $session->getRootNode();
21
        if ($rootNode->hasNode('test')) {
22
            $rootNode->getNode('test')->remove();
23
        }
24
25
        $rootNode->addNode('test');
26
    }
27
28 View Code Duplication
    protected function createImage($path, $width, $height, $mimeType)
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...
29
    {
30
        $image = new Image();
31
        $image->path = $path;
32
        $image->width = $width;
33
        $image->height = $height;
34
        $image->mimetype = $mimeType;
35
36
        return $image;
37
    }
38
39
    protected function createArticleSlideshow()
40
    {
41
        $article = new Article();
42
        $article->id = '/test/article';
43
44
        $image1 = $this->createImage('/path/to/image1', 100, 200, 'image/jpeg');
45
        $image2 = $this->createImage('/path/to/image2', 100, 200, 'image/jpeg');
46
        $image3 = $this->createImage('/path/to/image3', 100, 200, 'image/jpeg');
47
48
        $article->slideshow = [
49
            $image1,
50
            $image2,
51
            $image3,
52
        ];
53
54
        return $article;
55
    }
56
}
57