public function OnlyOneTest::testGetLanguageLabel in Allow a content type only once (Only One) 8
Tests the language label with OnlyOne::getLanguageLabel().
@covers ::getLanguageLabel @dataProvider providerGetLanguageLabel
Parameters
string $expected: The expected result from calling the function.
string $language_code: The language code to run through OnlyOne::getLanguageLabel().
File
- tests/
src/ Unit/ OnlyOneTest.php, line 406  
Class
- OnlyOneTest
 - Tests the OnlyOne class methods.
 
Namespace
Drupal\Tests\onlyone\UnitCode
public function testGetLanguageLabel($expected, $language_code) {
  // LanguageInterface mock.
  $language = $this
    ->createMock('Drupal\\Core\\Language\\LanguageInterface');
  // Mocking getName method.
  $language
    ->expects($this
    ->any())
    ->method('getName')
    ->willReturn($expected);
  // Mocking getLanguage method.
  $this->languageManager
    ->expects($this
    ->any())
    ->method('getLanguage')
    ->with($language_code)
    ->willReturn($language);
  // Testing the function.
  $this
    ->assertEquals($expected, $this->onlyOne
    ->getLanguageLabel($language_code));
}