Skip to content

Commit 2c47a89

Browse files
authored
Added tests & readme (#13)
* Added tests * Added readme * Do not tests patch branches
1 parent 25dcf6c commit 2c47a89

File tree

3 files changed

+74
-0
lines changed

3 files changed

+74
-0
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ cache:
77
branches:
88
except:
99
- /^analysis-.*$/
10+
- /^patch-.*$/
1011

1112
php:
1213
- 5.4

Readme.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Common classes and interfaces
2+
3+
[![Latest Version](https://img.shields.io/github/release/php-translation/common.svg?style=flat-square)](https://github.com/php-translation/common/releases)
4+
[![Build Status](https://img.shields.io/travis/php-translation/common.svg?style=flat-square)](https://travis-ci.org/php-translation/common)
5+
[![Code Coverage](https://img.shields.io/scrutinizer/coverage/g/php-translation/common.svg?style=flat-square)](https://scrutinizer-ci.com/g/php-translation/common)
6+
[![Quality Score](https://img.shields.io/scrutinizer/g/php-translation/common.svg?style=flat-square)](https://scrutinizer-ci.com/g/php-translation/common)
7+
[![Total Downloads](https://img.shields.io/packagist/dt/php-translation/common.svg?style=flat-square)](https://packagist.org/packages/php-translation/common)
8+
9+
10+
## Install
11+
12+
``` bash
13+
$ composer require php-translation/common
14+
```
15+
16+
## Documentation
17+
18+
Read the full documentation at [http://php-translation.readthedocs.io](http://php-translation.readthedocs.io/en/latest/).
19+

tests/Unit/Model/MessageTest.php

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
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+
public function testAccessors()
22+
{
23+
$message = new Message('key', 'domain', 'locale', 'translation');
24+
25+
$this->assertEquals('key', $message->getKey());
26+
$this->assertEquals('domain', $message->getDomain());
27+
$this->assertEquals('locale', $message->getLocale());
28+
$this->assertEquals('translation', $message->getTranslation());
29+
30+
$message->setKey('key_foo');
31+
$this->assertEquals('key_foo', $message->getKey());
32+
$message->setDomain('domain_foo');
33+
$this->assertEquals('domain_foo', $message->getDomain());
34+
$message->setLocale('locale_foo');
35+
$this->assertEquals('locale_foo', $message->getLocale());
36+
$message->setTranslation('trans_foo');
37+
$this->assertEquals('trans_foo', $message->getTranslation());
38+
}
39+
40+
public function testMeta()
41+
{
42+
$message = new Message('', '', '', '', ['foo' => 'bar']);
43+
44+
$this->assertEquals(['foo' => 'bar'], $message->getAllMeta());
45+
$this->assertEquals('bar', $message->getMeta('foo'));
46+
47+
$message->addMeta('key', 'value');
48+
$this->assertEquals('value', $message->getMeta('key'));
49+
50+
$message->setMeta(['new' => 'values']);
51+
$this->assertNull($message->getMeta('key'));
52+
$this->assertEquals('values', $message->getMeta('new'));
53+
}
54+
}

0 commit comments

Comments
 (0)