public function DeleteAssetsTest::setUp in Acquia Content Hub 8.2
Overrides UnitTestCase::setUp
File
- tests/
src/ Unit/ EventSubscriber/ HandleWebhook/ DeleteAssetsTest.php, line 99
Class
- DeleteAssetsTest
- Tests the DeleteAssets webhook event subscriber.
Namespace
Drupal\Tests\acquia_contenthub\Unit\EventSubscriber\HandleWebhookCode
public function setUp() {
$this->entity = $this
->prophesize(EntityBase::class);
$entity = $this->entity;
$this->contentHubSettings = $this
->prophesize(Settings::class);
$this->contentHubSettings
->getUuid()
->willReturn(self::CLIENT_UUID);
$this->contentHubSettings
->getWebhook("uuid")
->willReturn(self::WEBHOOK_UUID);
$this->contentHubClient = $this
->prophesize(ContentHubClient::class);
$this->contentHubClient
->getSettings()
->willReturn($this->contentHubSettings);
$this->clientFactory = $this
->prophesize(ClientFactory::class);
$this->clientFactory
->getClient()
->willReturn($this->contentHubClient);
$this->configFactory = $this
->prophesize(ConfigFactoryInterface::class);
$config = $this
->prophesize(Config::class);
$config
->get(Argument::any())
->willReturn(TRUE);
$this->configFactory
->getEditable(Argument::any())
->willReturn($config
->reveal());
$this->key = new Key('id', 'secret');
$this->request = $this
->prophesize(Request::class)
->reveal();
$this->tracker = $this
->prophesize(SubscriberTracker::class);
$this->tracker
->delete(Argument::type('string'));
$this->tracker
->getEntityByRemoteIdAndHash(Argument::type('string'))
->will(function ($uuid) use ($entity) {
switch (current($uuid)) {
case self::NON_EXISTING_ENTITY_UUID:
return NULL;
case self::EXISTING_ENTITY_UUID:
return $entity;
case self::EXISTING_DISCONNECTED_ENTITY_UUID:
return $entity;
}
});
$this->tracker
->getStatusByUuid(Argument::type('string'))
->will(function ($uuid) {
switch (current($uuid)) {
case self::EXISTING_DISCONNECTED_ENTITY_UUID:
return SubscriberTracker::AUTO_UPDATE_DISABLED;
default:
return SubscriberTracker::IMPORTED;
}
});
}