You are here

public function LingotekUnitTest::testGetVaultsWithNoData in Lingotek Translation 8

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

@covers ::getVaults

File

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

Class

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

Namespace

Drupal\Tests\lingotek\Unit

Code

public function testGetVaultsWithNoData() {

  // A call is performed when getting vaults and there are none locally.
  $this->config
    ->expects($this
    ->at(0))
    ->method('get')
    ->with('account.resources.vault')
    ->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('getVaults')
    ->will($this
    ->returnValue([
    'a_vault' => 'A vault',
  ]));

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