You are here

public function RestClientTest::setUp in Salesforce Suite 5.0.x

Same name and namespace in other branches
  1. 8.4 tests/src/Unit/RestClientTest.php \Drupal\Tests\salesforce\Unit\RestClientTest::setUp()
  2. 8.3 tests/src/Unit/RestClientTest.php \Drupal\Tests\salesforce\Unit\RestClientTest::setUp()

Set up for each test.

Overrides UnitTestCase::setUp

File

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

Class

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

Namespace

Drupal\Tests\salesforce\Unit

Code

public function setUp() : void {
  parent::setUp();
  $this->salesforce_id = '1234567890abcde';
  $this->methods = [
    'httpRequest',
  ];
  $this->httpClient = $this
    ->getMockBuilder(Client::CLASS)
    ->getMock();
  $this->configFactory = $this
    ->getMockBuilder(ConfigFactory::CLASS)
    ->disableOriginalConstructor()
    ->getMock();
  $this->state = $this
    ->getMockBuilder(State::CLASS)
    ->disableOriginalConstructor()
    ->getMock();
  $this->cache = $this
    ->getMockBuilder(CacheBackendInterface::CLASS)
    ->getMock();
  $this->json = $this
    ->getMockBuilder(Json::CLASS)
    ->getMock();
  $this->time = $this
    ->getMockBuilder(TimeInterface::CLASS)
    ->getMock();
  $this->authToken = $this
    ->getMockBuilder(TokenInterface::CLASS)
    ->getMock();
  $this->authProvider = $this
    ->getMockBuilder(SalesforceAuthProviderInterface::CLASS)
    ->disableOriginalConstructor()
    ->getMock();
  $this->authProvider
    ->expects($this
    ->any())
    ->method('getApiEndpoint')
    ->willReturn('https://example.com');
  $this->authConfig = $this
    ->getMockBuilder(SalesforceAuthConfig::CLASS)
    ->disableOriginalConstructor()
    ->getMock();
  $this->authMan = $this
    ->getMockBuilder(SalesforceAuthProviderPluginManager::CLASS)
    ->disableOriginalConstructor()
    ->getMock();
  $this->authMan
    ->expects($this
    ->any())
    ->method('getToken')
    ->willReturn($this->authToken);
  $this->authMan
    ->expects($this
    ->any())
    ->method('getProvider')
    ->willReturn($this->authProvider);
  $this->authMan
    ->expects($this
    ->any())
    ->method('getConfig')
    ->willReturn($this->authConfig);
  $this->authMan
    ->expects($this
    ->any())
    ->method('refreshToken')
    ->willReturn($this->authToken);
}