You are here

TelemetryTest.php in Lightning Core 8.4

Same filename and directory in other branches
  1. 8.3 modules/acquia_telemetry/tests/src/Kernel/TelemetryTest.php

File

modules/acquia_telemetry/tests/src/Kernel/TelemetryTest.php
View source
<?php

namespace Drupal\Tests\acquia_telemetry\Kernel;

use Drupal\KernelTests\KernelTestBase;
use GuzzleHttp\ClientInterface;
use Prophecy\Argument;

/**
 * @group lightning
 * @group lightning_core
 * @group acquia_telemetry
 *
 * @coversDefaultClass \Drupal\acquia_telemetry\Telemetry
 */
class TelemetryTest extends KernelTestBase {

  /**
   * {@inheritdoc}
   */
  protected static $modules = [
    'acquia_telemetry',
    'system',
  ];
  public function testErrorSuppression() {
    $http_client = $this
      ->prophesize(ClientInterface::class);
    $http_client
      ->request(Argument::cetera())
      ->willThrow('Exception');
    $this->container
      ->set('http_client', $http_client
      ->reveal());
    $telemetry = $this->container
      ->get('acquia.telemetry');
    $this
      ->assertFalse($telemetry
      ->sendTelemetry('Foobaz'));
    $this->container
      ->get('state')
      ->set('acquia_telemetry.loud', TRUE);
    $this
      ->setExpectedException('Exception');
    $telemetry
      ->sendTelemetry('Blow up real good!');
  }

}

Classes

Namesort descending Description
TelemetryTest @group lightning @group lightning_core @group acquia_telemetry