HooksTest.php in Lightning Core 8.4
File
modules/acquia_telemetry/tests/src/Kernel/HooksTest.php
View source
<?php
namespace Drupal\Tests\acquia_telemetry\Kernel;
use Drupal\acquia_telemetry\Telemetry;
use Drupal\KernelTests\KernelTestBase;
class HooksTest extends KernelTestBase {
protected static $modules = [
'acquia_telemetry',
'system',
];
private $telemetry;
protected function setUp() {
parent::setUp();
$this->telemetry = $this
->prophesize(Telemetry::class);
$this->container
->set('acquia.telemetry', $this->telemetry
->reveal());
}
public function testCron() {
$this->telemetry
->sendTelemetry('Drupal cron ran')
->shouldBeCalled();
$this->container
->get('cron')
->run();
}
public function testAcquiaExtensionInstall() {
$modules = [
'lightning_search',
];
$this->telemetry
->getAcquiaExtensionNames()
->willReturn($modules)
->shouldBeCalled();
$this->telemetry
->sendTelemetry('Acquia extensions installed', [
'installed_extensions' => $modules,
])
->shouldBeCalled();
acquia_telemetry_modules_installed($modules);
$this->telemetry
->sendTelemetry('Acquia extensions uninstalled', [
'uninstalled_extensions' => $modules,
])
->shouldBeCalled();
acquia_telemetry_modules_uninstalled($modules);
}
public function testAcquiaExtensionUninstall() {
$modules = [
'lightning_search',
];
$this->telemetry
->getAcquiaExtensionNames()
->willReturn($modules)
->shouldBeCalled();
$this->telemetry
->sendTelemetry('Acquia extensions uninstalled', [
'uninstalled_extensions' => $modules,
])
->shouldBeCalled();
acquia_telemetry_modules_uninstalled($modules);
}
}
Classes
Name |
Description |
HooksTest |
@group lightning
@group lightning_core
@group acquia_telemetry |