Completed
Push — master ( c3eba2...34879d )
by amaury
05:12 queued 01:44
created

Manager/ContentTypeManagerTest.php (5 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
namespace OpenOrchestra\FunctionalTests\BackofficeBundle\Manager;
4
5
use OpenOrchestra\Backoffice\Manager\ContentTypeManager;
6
use OpenOrchestra\BaseBundle\Tests\AbstractTest\AbstractKernelTestCase;
7
use OpenOrchestra\ModelInterface\Model\ContentTypeInterface;
8
9
/**
10
 * Class ContentTypeManagerTest
11
 *
12
 * @group integrationTest
13
 */
14
class ContentTypeManagerTest extends AbstractKernelTestCase
15
{
16
    /**
17
     * @var ContentTypeManager
18
     */
19
    protected $manager;
20
21
    protected $contentTypeRepository;
22
23
    /**
24
     * Set up the test
25
     */
26
    public function setUp()
27
    {
28
        static::bootKernel();
29
        $this->contentTypeRepository = static::$kernel->getContainer()->get('open_orchestra_model.repository.content_type');
30
31
        $this->manager = new ContentTypeManager(static::$kernel->getContainer()->getParameter('open_orchestra_model.document.content_type.class'));
32
    }
33
34
    /**
35
     * @param string $contentTypeId
36
     *
37
     * @dataProvider provideContentTypeId
38
     */
39
    public function testDuplicate($contentTypeId)
40
    {
41
        /** @var ContentTypeInterface $contentType */
42
        $contentType = $this->contentTypeRepository->findOneByContentTypeId($contentTypeId);
43
44
        /** @var ContentTypeInterface $newContentType */
45
        $newContentType = $this->manager->duplicate($contentType);
46
47
        $this->assertNull($newContentType->getId());
48
        $this->assertEquals($contentType->getVersion() + 1, $newContentType->getVersion());
49
        $this->assertCount(count($contentType->getNames()), $newContentType->getNames());
50
        $this->assertSame($contentType->getName('fr'), $newContentType->getName('fr'));
51
        $this->assertSame($contentType->getName('en'), $newContentType->getName('en'));
52
        $this->assertCount($contentType->getFields()->count(), $newContentType->getFields());
0 ignored issues
show
The method count cannot be called on $contentType->getFields() (of type array).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
53
        $this->assertCount(count($contentType->getFields()->first()->getLabels()), $newContentType->getFields()->first()->getLabels());
0 ignored issues
show
The method first cannot be called on $contentType->getFields() (of type array).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
The method first cannot be called on $newContentType->getFields() (of type array).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
54
        $this->assertSame($contentType->getFields()->first()->getLabel('fr'), $newContentType->getFields()->first()->getLabel('fr'));
0 ignored issues
show
The method first cannot be called on $contentType->getFields() (of type array).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
The method first cannot be called on $newContentType->getFields() (of type array).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
55
    }
56
57
    /**
58
     * @return array
59
     */
60
    public function provideContentTypeId()
61
    {
62
        return array(
63
            array('news'),
64
            array('car'),
65
            array('customer'),
66
        );
67
    }
68
}
69