ContentTypeControllerTest   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 68
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 5
dl 0
loc 68
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 5 1
A testFormController() 0 13 1
A testEditContent() 0 18 1
A testNewContent() 0 6 1
1
<?php
2
3
namespace OpenOrchestra\FunctionalTests\BackofficeBundle\Controller;
4
5
use OpenOrchestra\FunctionalTests\Utils\AbstractFormTest;
6
use OpenOrchestra\ModelInterface\Repository\ContentTypeRepositoryInterface;
7
8
/**
9
 * Class ContentTypeControllerTest
10
 *
11
 * @group backofficeTest
12
 */
13
class ContentTypeControllerTest extends AbstractFormTest
14
{
15
    /**
16
     * @var ContentTypeRepositoryInterface
17
     */
18
    protected $contentTypeRepository;
19
20
    protected $username = 'developer';
21
    protected $password = 'developer';
22
23
    /**
24
     * Set up the test
25
     */
26
    public function setUp()
27
    {
28
        parent::setUp();
29
        $this->contentTypeRepository = static::$kernel->getContainer()->get('open_orchestra_model.repository.content_type');
30
    }
31
32
    /**
33
     * Test content type versionnning
34
     */
35
    public function testFormController()
36
    {
37
         $contentTypes = $this->contentTypeRepository->findAll();
38
         $contentTypeCount = count($contentTypes);
39
40
         $crawler = $this->client->request('GET', '/admin/content-type/form/news');
41
         $form = $crawler->selectButton('Save')->form();
42
43
         $this->submitForm($form);
44
45
         $contentTypes = $this->contentTypeRepository->findAll();
46
         $this->assertCount($contentTypeCount + 1, $contentTypes);
47
    }
48
49
    /**
50
     * Test content edition
51
     */
52
    public function testEditContent()
53
    {
54
        $url = '/admin/content/form/notre_vision/fr';
55
        $crawler = $this->client->request('GET', $url);
56
        $this->assertNotContains('has-error', $this->client->getResponse()->getContent());
57
        $contentForm = $crawler->selectButton('Save')->form();
58
        $this->submitForm($contentForm);
59
        $this->assertContains('alert alert-success', $this->client->getResponse()->getContent());
60
61
        $crawler = $this->client->request('GET', '/admin/content-type/form/news');
62
        $form = $crawler->selectButton('Save')->form();
63
64
        $this->submitForm($form);
65
66
        $url = '/admin/content/form/notre_vision/fr';
67
        $this->client->request('GET', $url);
68
        $this->assertNotContains('has-error', $this->client->getResponse()->getContent());
69
    }
70
71
    /**
72
     * Test new content
73
     */
74
    public function testNewContent()
75
    {
76
        $url = '/admin/content/new/news/en';
77
        $this->client->request('GET', $url);
78
        $this->assertNotContains('has-error', $this->client->getResponse()->getContent());
79
    }
80
}
81