You are here

public function RestClientTest::testAuthorized in Salesforce Suite 8.3

@covers ::isAuthorized

File

tests/src/Unit/RestClientTest.php, line 92

Class

RestClientTest
@coversDefaultClass \Drupal\salesforce\Rest\RestClient @group salesforce

Namespace

Drupal\Tests\salesforce\Unit

Code

public function testAuthorized() {
  $this
    ->initClient();
  $this->client
    ->expects($this
    ->at(0))
    ->method('getConsumerKey')
    ->willReturn($this
    ->randomMachineName());
  $this->client
    ->expects($this
    ->at(1))
    ->method('getConsumerSecret')
    ->willReturn($this
    ->randomMachineName());
  $this->client
    ->expects($this
    ->at(2))
    ->method('getRefreshToken')
    ->willReturn($this
    ->randomMachineName());
  $this
    ->assertTrue($this->client
    ->isAuthorized());

  // Next one will fail because mocks only return for specific invocations.
  $this
    ->assertFalse($this->client
    ->isAuthorized());
}