You are here

public function LingotekNotificationControllerTest::testUnprocessedCallbackNotCached in Lingotek Translation 3.5.x

Same name and namespace in other branches
  1. 8.2 tests/src/Functional/Controller/LingotekNotificationControllerTest.php \Drupal\Tests\lingotek\Functional\Controller\LingotekNotificationControllerTest::testUnprocessedCallbackNotCached()
  2. 4.0.x tests/src/Functional/Controller/LingotekNotificationControllerTest.php \Drupal\Tests\lingotek\Functional\Controller\LingotekNotificationControllerTest::testUnprocessedCallbackNotCached()
  3. 3.0.x tests/src/Functional/Controller/LingotekNotificationControllerTest.php \Drupal\Tests\lingotek\Functional\Controller\LingotekNotificationControllerTest::testUnprocessedCallbackNotCached()
  4. 3.1.x tests/src/Functional/Controller/LingotekNotificationControllerTest.php \Drupal\Tests\lingotek\Functional\Controller\LingotekNotificationControllerTest::testUnprocessedCallbackNotCached()
  5. 3.2.x tests/src/Functional/Controller/LingotekNotificationControllerTest.php \Drupal\Tests\lingotek\Functional\Controller\LingotekNotificationControllerTest::testUnprocessedCallbackNotCached()
  6. 3.3.x tests/src/Functional/Controller/LingotekNotificationControllerTest.php \Drupal\Tests\lingotek\Functional\Controller\LingotekNotificationControllerTest::testUnprocessedCallbackNotCached()
  7. 3.4.x tests/src/Functional/Controller/LingotekNotificationControllerTest.php \Drupal\Tests\lingotek\Functional\Controller\LingotekNotificationControllerTest::testUnprocessedCallbackNotCached()
  8. 3.6.x tests/src/Functional/Controller/LingotekNotificationControllerTest.php \Drupal\Tests\lingotek\Functional\Controller\LingotekNotificationControllerTest::testUnprocessedCallbackNotCached()
  9. 3.7.x tests/src/Functional/Controller/LingotekNotificationControllerTest.php \Drupal\Tests\lingotek\Functional\Controller\LingotekNotificationControllerTest::testUnprocessedCallbackNotCached()
  10. 3.8.x tests/src/Functional/Controller/LingotekNotificationControllerTest.php \Drupal\Tests\lingotek\Functional\Controller\LingotekNotificationControllerTest::testUnprocessedCallbackNotCached()

Tests that a callback is never cached.

File

tests/src/Functional/Controller/LingotekNotificationControllerTest.php, line 131

Class

LingotekNotificationControllerTest
Tests the notification controller.

Namespace

Drupal\Tests\lingotek\Functional\Controller

Code

public function testUnprocessedCallbackNotCached() {

  // Simulate the notification of content successfully uploaded.
  $url = Url::fromRoute('lingotek.notify', [], [
    'query' => [
      'llamas' => 'cool',
    ],
  ])
    ->setAbsolute()
    ->toString();
  $request = $this->client
    ->get($url, [
    'headers' => [
      'Accept' => 'application/json',
      'Content-Type' => 'application/json',
    ],
    'http_errors' => FALSE,
  ]);
  $cache_control_header = $request
    ->getHeader('Cache-Control');
  $this
    ->assertStringContainsString('max-age=0', $cache_control_header[0]);
  $response = (string) $request
    ->getBody();
  $this
    ->assertIdentical($response, 'It works, but nothing to look here.');

  // Simulate again the notification of content successfully uploaded.
  $request = $this->client
    ->get($url, [
    'headers' => [
      'Accept' => 'application/json',
      'Content-Type' => 'application/json',
    ],
    'http_errors' => FALSE,
  ]);
  $cache_control_header = $request
    ->getHeader('Cache-Control');
  $this
    ->assertStringContainsString('max-age=0', $cache_control_header[0]);
  $response = (string) $request
    ->getBody();
  $this
    ->assertIdentical($response, 'It works, but nothing to look here.');
}