You are here

public function LingotekUnitTest::testGetProjectsWithNoData in Lingotek Translation 8

Same name and namespace in other branches
  1. 8.2 tests/src/Unit/LingotekUnitTest.php \Drupal\Tests\lingotek\Unit\LingotekUnitTest::testGetProjectsWithNoData()
  2. 4.0.x tests/src/Unit/LingotekUnitTest.php \Drupal\Tests\lingotek\Unit\LingotekUnitTest::testGetProjectsWithNoData()
  3. 3.0.x tests/src/Unit/LingotekUnitTest.php \Drupal\Tests\lingotek\Unit\LingotekUnitTest::testGetProjectsWithNoData()
  4. 3.1.x tests/src/Unit/LingotekUnitTest.php \Drupal\Tests\lingotek\Unit\LingotekUnitTest::testGetProjectsWithNoData()
  5. 3.2.x tests/src/Unit/LingotekUnitTest.php \Drupal\Tests\lingotek\Unit\LingotekUnitTest::testGetProjectsWithNoData()
  6. 3.3.x tests/src/Unit/LingotekUnitTest.php \Drupal\Tests\lingotek\Unit\LingotekUnitTest::testGetProjectsWithNoData()
  7. 3.4.x tests/src/Unit/LingotekUnitTest.php \Drupal\Tests\lingotek\Unit\LingotekUnitTest::testGetProjectsWithNoData()
  8. 3.5.x tests/src/Unit/LingotekUnitTest.php \Drupal\Tests\lingotek\Unit\LingotekUnitTest::testGetProjectsWithNoData()
  9. 3.6.x tests/src/Unit/LingotekUnitTest.php \Drupal\Tests\lingotek\Unit\LingotekUnitTest::testGetProjectsWithNoData()
  10. 3.7.x tests/src/Unit/LingotekUnitTest.php \Drupal\Tests\lingotek\Unit\LingotekUnitTest::testGetProjectsWithNoData()
  11. 3.8.x tests/src/Unit/LingotekUnitTest.php \Drupal\Tests\lingotek\Unit\LingotekUnitTest::testGetProjectsWithNoData()

@covers ::getProjects

File

tests/src/Unit/LingotekUnitTest.php, line 181

Class

LingotekUnitTest
@coversDefaultClass \Drupal\lingotek\Lingotek @group lingotek @preserveGlobalState disabled

Namespace

Drupal\Tests\lingotek\Unit

Code

public function testGetProjectsWithNoData() {

  // A call is performed when getting projects and there are none locally.
  $this->config
    ->expects($this
    ->at(0))
    ->method('get')
    ->with('account.resources.project')
    ->will($this
    ->returnValue([]));
  $this->config
    ->expects($this
    ->at(1))
    ->method('get')
    ->with('default.community')
    ->will($this
    ->returnValue([
    'my_community',
  ]));

  // Ensure the call will be made.
  $this->api
    ->expects($this
    ->once())
    ->method('getProjects')
    ->will($this
    ->returnValue([
    'a_project' => 'A project',
  ]));

  // And the results will be stored.
  $this->config
    ->expects($this
    ->at(2))
    ->method('set')
    ->with('account.resources.project', [
    'a_project' => 'A project',
  ])
    ->will($this
    ->returnSelf());
  $this->config
    ->expects($this
    ->at(3))
    ->method('save');
  $this->config
    ->expects($this
    ->at(4))
    ->method('get')
    ->with('default.project')
    ->will($this
    ->returnValue(NULL));
  $this->config
    ->expects($this
    ->at(5))
    ->method('set')
    ->with('default.project', 'a_project')
    ->will($this
    ->returnSelf());
  $this->config
    ->expects($this
    ->at(6))
    ->method('save');
  $this->lingotek
    ->getProjects(FALSE);
}