Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ cache:
branches:
except:
- /^analysis-.*$/
- /^patch-.*$/

php:
- 5.4
Expand Down
19 changes: 19 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Common classes and interfaces

[![Latest Version](https://img.shields.io/github/release/php-translation/common.svg?style=flat-square)](https://github.com/php-translation/common/releases)
[![Build Status](https://img.shields.io/travis/php-translation/common.svg?style=flat-square)](https://travis-ci.org/php-translation/common)
[![Code Coverage](https://img.shields.io/scrutinizer/coverage/g/php-translation/common.svg?style=flat-square)](https://scrutinizer-ci.com/g/php-translation/common)
[![Quality Score](https://img.shields.io/scrutinizer/g/php-translation/common.svg?style=flat-square)](https://scrutinizer-ci.com/g/php-translation/common)
[![Total Downloads](https://img.shields.io/packagist/dt/php-translation/common.svg?style=flat-square)](https://packagist.org/packages/php-translation/common)


## Install

``` bash
$ composer require php-translation/common
```

## Documentation

Read the full documentation at [http://php-translation.readthedocs.io](http://php-translation.readthedocs.io/en/latest/).

54 changes: 54 additions & 0 deletions tests/Unit/Model/MessageTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?php

/*
* This file is part of the PHP Translation package.
*
* (c) PHP Translation team <tobias.nyholm@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Translation\common\tests\Unit\Model;

use Translation\Common\Model\Message;

/**
* @author Tobias Nyholm <tobias.nyholm@gmail.com>
*/
class MessageTest extends \PHPUnit_Framework_TestCase
{
public function testAccessors()
{
$message = new Message('key', 'domain', 'locale', 'translation');

$this->assertEquals('key', $message->getKey());
$this->assertEquals('domain', $message->getDomain());
$this->assertEquals('locale', $message->getLocale());
$this->assertEquals('translation', $message->getTranslation());

$message->setKey('key_foo');
$this->assertEquals('key_foo', $message->getKey());
$message->setDomain('domain_foo');
$this->assertEquals('domain_foo', $message->getDomain());
$message->setLocale('locale_foo');
$this->assertEquals('locale_foo', $message->getLocale());
$message->setTranslation('trans_foo');
$this->assertEquals('trans_foo', $message->getTranslation());
}

public function testMeta()
{
$message = new Message('', '', '', '', ['foo' => 'bar']);

$this->assertEquals(['foo' => 'bar'], $message->getAllMeta());
$this->assertEquals('bar', $message->getMeta('foo'));

$message->addMeta('key', 'value');
$this->assertEquals('value', $message->getMeta('key'));

$message->setMeta(['new' => 'values']);
$this->assertNull($message->getMeta('key'));
$this->assertEquals('values', $message->getMeta('new'));
}
}