From 9c5a18f909588ce02412458ea9b62b31c828c95d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=ABl=20Gaujard?= Date: Wed, 7 Nov 2018 23:14:39 +0100 Subject: [PATCH] Add unit test and documentation about this new method --- README.md | 4 ++++ tests/ISO639Test.php | 13 +++++++++++++ 2 files changed, 17 insertions(+) diff --git a/README.md b/README.md index c308e6c..f12c5b9 100644 --- a/README.md +++ b/README.md @@ -60,6 +60,10 @@ echo $iso->nativeByCode3('eng'); // English echo $iso->nativeByCode3('ind'); // Bahasa Indonesia echo $iso->nativeByCode3('jav'); // basa Jawa +// Get language array from ISO-639-2b code +echo $iso->getLanguageByIsoCode2b('eng'); // ['en', 'eng', 'eng', 'eng', 'English', 'English'] +echo $iso->getLanguageByIsoCode2b('ind'); // ['id', 'ind', 'ind', 'ind', 'Indonesian', 'Bahasa Indonesia'] +echo $iso->getLanguageByIsoCode2b('jav'); // ['jv', 'jav', 'jav', 'jav', 'Javanese', 'basa Jawa'] ``` ## To Do diff --git a/tests/ISO639Test.php b/tests/ISO639Test.php index b4f22ed..5a5b4bc 100644 --- a/tests/ISO639Test.php +++ b/tests/ISO639Test.php @@ -236,4 +236,17 @@ public function testISO6393Language() $this->assertSame('msa', $this->iso->code3ByLanguage('Malay')); $this->assertSame('sun', $this->iso->code3ByLanguage('Sundanese')); } + + public function testGetLanguageByIsoCode2B() + { + $result = ['en', 'eng', 'eng', 'eng', 'English', 'English']; + $this->assertSame($result, $this->iso->getLanguageByIsoCode2b('eng')); + $result = ['fr', 'fra', 'fre', 'fra', 'French', 'français, langue française']; + $this->assertSame($result, $this->iso->getLanguageByIsoCode2b('fre')); + $result = ['id', 'ind', 'ind', 'ind', 'Indonesian', 'Bahasa Indonesia']; + $this->assertSame($result, $this->iso->getLanguageByIsoCode2b('ind')); + + $this->assertNull($this->iso->getLanguageByIsoCode2b('null')); + } + }