Completed
Push — master ( 25dcf6...2c47a8 )
by Tobias
02:51
created

MessageTest::testMeta()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 14
ccs 10
cts 10
cp 1
rs 9.4285
c 1
b 0
f 0
cc 1
eloc 9
nc 1
nop 0
crap 1
1
<?php
2
3
/*
4
 * This file is part of the PHP Translation package.
5
 *
6
 * (c) PHP Translation team <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Translation\common\tests\Unit\Model;
13
14
use Translation\Common\Model\Message;
15
16
/**
17
 * @author Tobias Nyholm <[email protected]>
18
 */
19
class MessageTest extends \PHPUnit_Framework_TestCase
20
{
21 1
    public function testAccessors()
22
    {
23 1
        $message = new Message('key', 'domain', 'locale', 'translation');
24
25 1
        $this->assertEquals('key', $message->getKey());
26 1
        $this->assertEquals('domain', $message->getDomain());
27 1
        $this->assertEquals('locale', $message->getLocale());
28 1
        $this->assertEquals('translation', $message->getTranslation());
29
30 1
        $message->setKey('key_foo');
31 1
        $this->assertEquals('key_foo', $message->getKey());
32 1
        $message->setDomain('domain_foo');
33 1
        $this->assertEquals('domain_foo', $message->getDomain());
34 1
        $message->setLocale('locale_foo');
35 1
        $this->assertEquals('locale_foo', $message->getLocale());
36 1
        $message->setTranslation('trans_foo');
37 1
        $this->assertEquals('trans_foo', $message->getTranslation());
38 1
    }
39
40 1
    public function testMeta()
41
    {
42 1
        $message = new Message('', '', '', '', ['foo' => 'bar']);
43
44 1
        $this->assertEquals(['foo' => 'bar'], $message->getAllMeta());
45 1
        $this->assertEquals('bar', $message->getMeta('foo'));
46
47 1
        $message->addMeta('key', 'value');
48 1
        $this->assertEquals('value', $message->getMeta('key'));
49
50 1
        $message->setMeta(['new' => 'values']);
51 1
        $this->assertNull($message->getMeta('key'));
52 1
        $this->assertEquals('values', $message->getMeta('new'));
53 1
    }
54
}
55