|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace test\integration; |
| 4 | + |
| 5 | +use Google\ApiCore\CredentialsWrapper; |
| 6 | +use Google\Cloud\Tasks\V2\CloudTasksClient; |
| 7 | +use Ingenerator\CloudTasksWrapper\Client\CloudTasksClientFactory; |
| 8 | +use PHPUnit\Framework\TestCase; |
| 9 | +use Psr\Cache\CacheItemPoolInterface; |
| 10 | + |
| 11 | +class CloudTasksClientFactoryTest extends TestCase |
| 12 | +{ |
| 13 | + |
| 14 | + public function test_it_can_create_client_when_called_with_emulator_configuration() |
| 15 | + { |
| 16 | + $cache = $this->getMockBuilder(CacheItemPoolInterface::class)->getMock(); |
| 17 | + $client = CloudTasksClientFactory::makeClient($cache, [ |
| 18 | + 'use_emulator' => true, |
| 19 | + 'emulator_endpoint' => 'cloud_tasks_emulator:8123', |
| 20 | + 'credentials' => null |
| 21 | + ]); |
| 22 | + $this->assertInstanceOf(CloudTasksClient::class, $client); |
| 23 | + } |
| 24 | + |
| 25 | + public function test_it_can_create_client_when_called_with_production_configuration() |
| 26 | + { |
| 27 | + $cache = $this->getMockBuilder(CacheItemPoolInterface::class)->getMock(); |
| 28 | + $client = CloudTasksClientFactory::makeClient($cache, [ |
| 29 | + 'use_emulator' => false, |
| 30 | + // NB that the emulator_endpoint is not relevant here, but it doesn't matter |
| 31 | + // if a project still provides it. |
| 32 | + 'emulator_endpoint' => 'cloud_tasks_emulator:8123', |
| 33 | + 'credentials' => $this->getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(), |
| 34 | + ]); |
| 35 | + $this->assertInstanceOf(CloudTasksClient::class, $client); |
| 36 | + } |
| 37 | +} |
0 commit comments