MemcachedLoaderTest::getMessagesArray()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 9
rs 9.6666
cc 1
eloc 5
nc 1
nop 0
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