You are here

public function LingotekNodeNotificationCallbackTest::testNotificationCallbacksOnMissingDocuments in Lingotek Translation 4.0.x

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

Tests notification callbacks when the documents have been deleted.

File

tests/src/Functional/LingotekNodeNotificationCallbackTest.php, line 1302

Class

LingotekNodeNotificationCallbackTest
Tests translating a node using the notification callback.

Namespace

Drupal\Tests\lingotek\Functional

Code

public function testNotificationCallbacksOnMissingDocuments() {

  // Simulate the notification of content successfully uploaded.
  $url = Url::fromRoute('lingotek.notify', [], [
    'query' => [
      'project_id' => 'test_project',
      'document_id' => 'missing-document-id',
      'complete' => 'false',
      'type' => 'document_uploaded',
      'progress' => '0',
    ],
  ])
    ->setAbsolute()
    ->toString();
  $request = $this->client
    ->post($url, [
    'cookies' => $this->cookies,
    'headers' => [
      'Accept' => 'application/json',
      'Content-Type' => 'application/json',
    ],
    'http_errors' => FALSE,
  ]);
  $this
    ->assertEquals($request
    ->getStatusCode(), Response::HTTP_NO_CONTENT);

  // Simulate the notification of content successfully translated.
  $url = Url::fromRoute('lingotek.notify', [], [
    'query' => [
      'project_id' => 'test_project',
      'document_id' => 'missing-document-id',
      'locale_code' => 'es-ES',
      'locale' => 'es_ES',
      'complete' => 'true',
      'type' => 'target',
      'progress' => '100',
    ],
  ])
    ->setAbsolute()
    ->toString();
  $request = $this->client
    ->post($url, [
    'cookies' => $this->cookies,
    'headers' => [
      'Accept' => 'application/json',
      'Content-Type' => 'application/json',
    ],
    'http_errors' => FALSE,
  ]);
  $this
    ->assertEquals($request
    ->getStatusCode(), Response::HTTP_NO_CONTENT);
}