Skip to content

Commit

Permalink
Created test for all languages
Browse files Browse the repository at this point in the history
  • Loading branch information
Zemistr committed Mar 17, 2015
1 parent 4c82a34 commit c47996d
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions tests/LanguagesTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php
use l10n\Language\ILanguage;

class LanguagesTest extends PHPUnit_Framework_TestCase {
public function filesProvider() {
$data = array();
$files = @glob(__DIR__ . '/../src/l10n/Language/*.php') ?: array();

foreach ($files as $file) {
$name = basename($file, '.php');

if ("ILanguage" != $name) {
$data[] = array("l10n\\Language\\$name");
}
}

return $data;
}

/**
* @dataProvider filesProvider
* @param $class
*/
public function testGetters($class) {
/** @var ILanguage $language */
$language = new $class;

$this->assertInternalType('string', $language->getIso639_1());
$this->assertInternalType('string', $language->getIso639_2());
$this->assertInternalType('string', $language->getEnglishName());
$this->assertInternalType('string', $language->getOriginalName());
$this->assertInternalType('bool', $language->isRtl());

$this->assertSame(2, $length = strlen($language->getIso639_1()), 'ISO 639-1 code must be 2 characters long.');
$this->assertSame(3, $length = strlen($language->getIso639_2()), 'ISO 639-2 code must be 3 characters long.');
}
}

0 comments on commit c47996d

Please sign in to comment.