You are here

public function LingotekUnitTest::testGetProjectsWithDataButForcing in Lingotek Translation 8

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

@covers ::getProjects

File

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

Class

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

Namespace

Drupal\Tests\lingotek\Unit

Code

public function testGetProjectsWithDataButForcing() {

  // A call is performed when forced even if there are projects locally.
  $this->config
    ->expects($this
    ->at(0))
    ->method('get')
    ->with('account.resources.project')
    ->will($this
    ->returnValue([
    'a_project' => 'A project',
  ]));
  $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(TRUE);
}