acquia_search-3.0.1/tests/src/Unit/AcquiaGuzzleDebugTest.php

tests/src/Unit/AcquiaGuzzleDebugTest.php
<?php

namespace Drupal\Tests\acquia_search\Unit;

use Drupal\acquia_search\Client\Solarium\AcquiaGuzzle;
use Drupal\Tests\UnitTestCase;
use GuzzleHttp\Client;

/**
 * Tests whether Acquia Guzzle client has debug option or not.
 *
 * @group acquia_search
 */
class AcquiaGuzzleDebugTest extends UnitTestCase {

  /**
   * {@inheritdoc}
   */
  protected function setUp(): void {
    parent::setUp();
    // The getConfig() method of Client object is deprecated and will be
    // removed in guzzlehttp/guzzle:8.0 and as of today there's no alternative.
    // Hence, used Reflection class to get debug.
    $this->reflection = new \ReflectionProperty(Client::class, 'config');
    $this->reflection->setAccessible(TRUE);
  }

  /**
   * Tests that debug is false in default setup.
   */
  public function testDebugNotAvailableOnDefault(): void {

    $client = new AcquiaGuzzle();
    self::assertFalse($this->reflection->getValue($client)['debug']);
  }

  /**
   * Tests that debug is true when env var is set.
   */
  public function testDebugAvailableWithEnvVar(): void {
    putenv("ACQUIA_GUZZLE_DEBUG=ENABLED");
    $client = new AcquiaGuzzle();
    self::assertTrue($this->reflection->getValue($client)['debug']);
  }

  /**
   * Tests that debug is true when superglobal is set.
   */
  public function testDebugAvailableWithGet(): void {
    // phpcs:ignore
    $_GET['debug'] = TRUE;
    $client = new AcquiaGuzzle();
    self::assertTrue($this->reflection->getValue($client)['debug']);
  }

}

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc