Unverified Commit 95df9e91 authored by Alex Pott's avatar Alex Pott
Browse files

task: #3585505 Refactor tests code via Rector

By: mondrake
parent fd70826e
Loading
Loading
Loading
Loading
Loading
+32 −1640

File changed.

Preview size limit exceeded, changes collapsed.

+1 −1
Original line number Diff line number Diff line
@@ -53,7 +53,7 @@ public function setUp():void {
   * @legacy-covers \Drupal\announcements_feed\AnnounceFetcher::validateUrl
   */
  #[DataProvider('urlProvider')]
  public function testValidateUrl($url, $isValid): void {
  public function testValidateUrl(string $url, bool $isValid): void {
    $this->assertEquals($isValid, $this->fetcher->validateUrl($url));
  }

+1 −1
Original line number Diff line number Diff line
@@ -214,7 +214,7 @@ public function testUnauthorizedErrorMessage(): void {
  public function testCacheabilityOf401Response(): void {
    $url = Url::fromRoute('router_test.11');

    $assert_response_cacheability = function ($expected_page_cache_header_value, $expected_dynamic_page_cache_header_sub_request_value) use ($url) {
    $assert_response_cacheability = function (string|int|float|bool|null $expected_page_cache_header_value, $expected_dynamic_page_cache_header_sub_request_value) use ($url): void {
      $this->drupalGet($url);
      $this->assertSession()->statusCodeEquals(401);
      $this->assertSession()->responseHeaderEquals('X-Drupal-Cache', $expected_page_cache_header_value);
+5 −5
Original line number Diff line number Diff line
@@ -40,7 +40,7 @@ class BigPipeResponseAttachmentsProcessorTest extends UnitTestCase {
   * @legacy-covers ::processAttachments
   */
  #[DataProvider('nonHtmlResponseProvider')]
  public function testNonHtmlResponse($response_class): void {
  public function testNonHtmlResponse(string $response_class): void {
    $big_pipe_response_attachments_processor = $this->createBigPipeResponseAttachmentsProcessor($this->prophesize(AttachmentsResponseProcessorInterface::class));

    $non_html_response = new $response_class();
@@ -51,7 +51,7 @@ public function testNonHtmlResponse($response_class): void {
  /**
   * Provides data to testNonHtmlResponse().
   */
  public static function nonHtmlResponseProvider() {
  public static function nonHtmlResponseProvider(): array {
    return [
      'AjaxResponse, which implements AttachmentsInterface' => [AjaxResponse::class],
      'A dummy that implements AttachmentsInterface' => [get_class((new Prophet())->prophesize(AttachmentsInterface::class)->reveal())],
@@ -72,7 +72,7 @@ public function testHtmlResponse(array $attachments): void {
    // service (that is this mock) never receives BigPipe placeholder
    // attachments, because it doesn't know (nor should it) how to handle them.
    $html_response_attachments_processor = $this->prophesize(AttachmentsResponseProcessorInterface::class);
    $html_response_attachments_processor->processAttachments(Argument::that(function ($response) {
    $html_response_attachments_processor->processAttachments(Argument::that(function ($response): bool {
      return $response instanceof HtmlResponse
        && empty(array_intersect(['big_pipe_placeholders', 'big_pipe_nojs_placeholders'], array_keys($response->getAttachments())));
    }))
@@ -102,7 +102,7 @@ public function testHtmlResponse(array $attachments): void {
  /**
   * Provides data to testHtmlResponse().
   */
  public static function attachmentsProvider() {
  public static function attachmentsProvider(): array {
    $typical_cases = [
      'no attachments' => [[]],
      'libraries' => [['library' => ['core/drupal']]],
@@ -154,7 +154,7 @@ public static function attachmentsProvider() {
   * @return \Drupal\big_pipe\Render\BigPipeResponseAttachmentsProcessor
   *   The BigPipeResponseAttachmentsProcessor to test.
   */
  protected function createBigPipeResponseAttachmentsProcessor(ObjectProphecy $decorated_html_response_attachments_processor) {
  protected function createBigPipeResponseAttachmentsProcessor(ObjectProphecy $decorated_html_response_attachments_processor): BigPipeResponseAttachmentsProcessor {
    return new BigPipeResponseAttachmentsProcessor(
      $decorated_html_response_attachments_processor->reveal(),
      $this->prophesize(AssetResolverInterface::class)->reveal(),
+2 −2
Original line number Diff line number Diff line
@@ -105,7 +105,7 @@ public function testLongPlaceholderFiberSuspendingLoop(): void {

    // Capture the result to avoid PHPUnit complaining.
    ob_start();
    $fiber = new \Fiber(function () use ($bigpipe, $response) {
    $fiber = new \Fiber(function () use ($bigpipe, $response): void {
      $bigpipe->sendContent($response);
    });
    $fiber->start();
@@ -143,7 +143,7 @@ public static function turtle(): array {
  /**
   * {@inheritdoc}
   */
  public static function trustedCallbacks() {
  public static function trustedCallbacks(): array {
    return ['turtle'];
  }

Loading