cloud-8.x-2.0-beta1/modules/cloud_service_providers/aws_cloud/tests/src/Unit/Service/Ec2/Ec2ServiceTest.php
modules/cloud_service_providers/aws_cloud/tests/src/Unit/Service/Ec2/Ec2ServiceTest.php
<?php
namespace Drupal\Tests\aws_cloud\Unit\Service\Ec2;
use Drupal\Tests\UnitTestCase;
/**
* Tests AWS Cloud Service.
*
* @group AWS Cloud
*/
class Ec2ServiceTest extends UnitTestCase {
/**
* {@inheritdoc}
*/
protected function setUp() {
$this->service = new Ec2ServiceMock(
$this->createMock('Drupal\Core\Entity\EntityTypeManagerInterface'),
$this->createMock('Drupal\Core\Logger\LoggerChannelFactoryInterface'),
$this->getConfigFactoryStub([
'aws_cloud.settings' => ['aws_cloud_test_mode' => TRUE],
]),
$this->getMockBuilder('Drupal\Core\Messenger\Messenger')
->disableOriginalConstructor()
->getMock(),
$this->getStringTranslationStub(),
$this->createMock('Drupal\Core\Session\AccountInterface'),
$this->createMock('Drupal\cloud\Plugin\cloud\config\CloudConfigPluginManagerInterface'),
$this->createMock('Drupal\Core\Field\FieldTypePluginManagerInterface'),
$this->createMock('Drupal\Core\Entity\EntityFieldManagerInterface'),
$this->createMock('Drupal\Core\Lock\LockBackendInterface')
);
}
/**
* Testing get availability zones.
*/
public function testGetAvailabilityZones() {
$random = $this->getRandomGenerator();
$zones = [];
$zones[] = $random->name(8, TRUE);
$zones[] = $random->name(8, TRUE);
$zones[] = $random->name(8, TRUE);
$responseZones = [];
$responseZones['AvailabilityZones'] = array_map(function ($zone) {
return ['ZoneName' => $zone];
}, $zones);
$this->service->setAvailabilityZonesForTest($responseZones);
$expectedResult = array_combine($zones, $zones);
$actualResult = $this->service->getAvailabilityZones();
$this->assertSame($expectedResult, $actualResult);
}
}
