Skip to content
Snippets Groups Projects
Commit 16b87f7f authored by Demian Katz's avatar Demian Katz
Browse files

Improved test coverage.

parent 3f5dbe00
No related merge requests found
......@@ -54,6 +54,48 @@ class TranslateTest extends \PHPUnit_Framework_TestCase
);
}
/**
* Test invalid translation array
*
* @return void
*
* @expectedException Exception
* @expectedExceptionMessage Unexpected value sent to translator!
*/
public function testTranslateWithEmptyArray()
{
$translate = new Translate();
$translate->__invoke([]);
}
/**
* Test invalid translation array
*
* @return void
*
* @expectedException Exception
* @expectedExceptionMessage Unexpected value sent to translator!
*/
public function testTranslateWithOverfilledArray()
{
$translate = new Translate();
$translate->__invoke([1, 2, 3]);
}
/**
* Test invalid translation string
*
* @return void
*
* @expectedException Exception
* @expectedExceptionMessage Unexpected value sent to translator!
*/
public function testTranslateWithDoubleTextDomainArray()
{
$translate = new Translate();
$translate->__invoke('a::b::c');
}
/**
* Test translation with a loaded translator
*
......@@ -70,6 +112,20 @@ class TranslateTest extends \PHPUnit_Framework_TestCase
$this->assertEquals('baz', $translate->__invoke(
'foo', ['%%token%%' => 'baz'], 'failure')
);
// Test namespace syntax:
$this->assertEquals('baz', $translate->__invoke(
'default::foo', ['%%token%%' => 'baz'], 'failure')
);
// Test array syntax:
$this->assertEquals('baz', $translate->__invoke(
['foo'], ['%%token%%' => 'baz'], 'failure')
);
$this->assertEquals('baz', $translate->__invoke(
[null, 'foo'], ['%%token%%' => 'baz'], 'failure')
);
$this->assertEquals('baz', $translate->__invoke(
['default', 'foo'], ['%%token%%' => 'baz'], 'failure')
);
}
/**
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment