MemcachedLoaderTest   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 3
Bugs 0 Features 3
Metric Value
wmc 4
c 3
b 0
f 3
lcom 1
cbo 3
dl 0
loc 59
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A tearDown() 0 4 1
A testLoad() 0 10 1
A setUp() 0 9 1
A getMessagesArray() 0 9 1
1
<?php
2
3
namespace Sleepness\UberTranslationBundle\Tests\Translation\Loader;
4
5
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
6
use Symfony\Component\Translation\MessageCatalogue;
7
8
/**
9
 * Test MemcacheLoader and cases
10
 *
11
 * @author Viktor Novikov <[email protected]>
12
 */
13
class MemcachedLoaderTest extends WebTestCase
14
{
15
    /**
16
     * @var \Sleepness\UberTranslationBundle\Storage\UberMemcached;
17
     */
18
    private $uberMemcached;
19
20
    /**
21
     * @var \Sleepness\UberTranslationBundle\Translation\Loader\MemcachedLoader;
22
     */
23
    private $loader;
24
25
    public function testLoad()
26
    {
27
        $catalogue = $this->loader->load($this->uberMemcached, 'en_US');
28
        $domains = $catalogue->getDomains();
29
30
        $this->assertTrue(is_object($catalogue));
31
        $this->assertTrue($catalogue instanceof MessageCatalogue);
32
        $this->assertEquals('en_US', $catalogue->getLocale());
33
        $this->assertEquals('messages', $domains[0]);
34
    }
35
36
    /**
37
     * Set up fixtures for testing
38
     */
39
    public function setUp()
40
    {
41
        static::bootKernel(array());
42
        $container = static::$kernel->getContainer();
43
        $this->uberMemcached = $container->get('uber.memcached');
44
        $this->loader = $container->get('uber.translation.loader');
45
        $values = $this->getMessagesArray();
46
        $this->uberMemcached->addItem('en_US', $values);
47
    }
48
49
    /**
50
     * Tear down fixtures after testing
51
     */
52
    public function tearDown()
53
    {
54
        $this->uberMemcached->deleteItem('en_US');
55
    }
56
57
    /**
58
     * Get messages for testing
59
     *
60
     * @return array - messages
61
     */
62
    private function getMessagesArray()
63
    {
64
        return array(
65
            'messages' => array(
66
                'key.hello' => 'value.Hello',
67
                'key.foo'   => 'value.Foo',
68
            ),
69
        );
70
    }
71
} 
72