LanguageTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 3
dl 0
loc 57
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
B testCreateLanguage() 0 27 1
B initLanguage() 0 24 1
1
<?php
2
3
class LanguageTest extends \WebCMS\Tests\EntityTestCase
4
{
5
    protected $language;
6
7
    public function testCreateLanguage()
8
    {
9
        $this->initLanguage();
10
11
        $this->em->persist($this->language);
12
        $this->em->flush();
13
14
        $languages = $this->em->getRepository('WebCMS\Entity\Language')->findAll();
15
16
        $this->assertEquals(1, count($languages));
17
        $this->assertEquals('cs', $languages[0]->getAbbr());
18
        $this->assertEquals(true, $languages[0]->getDefaultBackend());
19
        $this->assertEquals(true, $languages[0]->getDefaultFrontend());
20
        $this->assertEquals('utf-8', $languages[0]->getLocale());
21
        $this->assertEquals('Czech', $languages[0]->getName());
22
        $this->assertEquals(1, count($languages[0]->getTranslations()));
23
        $this->assertEquals('test', $languages[0]->getTranslations()[0]->getKey());
24
25
        $this->em->remove($languages[0]->getTranslations()[0]);
26
        $this->em->remove($languages[0]);
27
28
        $this->em->flush();
29
30
        $languages = $this->em->getRepository('WebCMS\Entity\Language')->findAll();
31
32
        $this->assertCount(0, $languages);
33
    }
34
35
    private function initLanguage()
36
    {
37
        $this->language = new \WebCMS\Entity\Language();
38
        $this->language->setAbbr('cs');
39
        $this->language->setDefaultBackend(true);
40
        $this->language->setDefaultFrontend(true);
41
        $this->language->setLocale('utf-8');
42
        $this->language->setName('Czech');
43
44
        $translations = array();
45
46
        $t = new \WebCMS\Entity\Translation();
47
        $t->setBackend(true);
48
        $t->setKey('test');
49
        $t->setTranslation('translation');
50
51
        $translations[] = $t;
52
        $this->language->setTranslations($translations);
53
54
        $t->setLanguage($this->language);
55
        $t->setHash();
56
57
        $this->em->persist($t);
58
    }
59
}
60