You are here

public function EmitControllerTest::testEmitInvalidRequest in Radioactivity 8.3

Same name and namespace in other branches
  1. 4.0.x tests/src/Unit/EmitControllerTest.php \Drupal\Tests\radioactivity\Unit\EmitControllerTest::testEmitInvalidRequest()

@covers ::emit

File

tests/src/Unit/EmitControllerTest.php, line 115

Class

EmitControllerTest
@coversDefaultClass \Drupal\radioactivity\Controller\EmitController @group radioactivity

Namespace

Drupal\Tests\radioactivity\Unit

Code

public function testEmitInvalidRequest() {
  $postData = Json::encode([
    [
      'fn' => 'field_name',
      'et' => 'entity_type',
      'id' => '99',
      'e' => 5.5,
      'h' => '',
    ],
  ]);
  $this->request
    ->getContent()
    ->willReturn($postData);
  $controller = EmitController::create($this->container
    ->reveal());
  $response = $controller
    ->emit($this->request
    ->reveal());
  $this->defaultIncidentStorage
    ->addIncident(Argument::type(IncidentInterface::class))
    ->shouldNotBeCalled(0);
  $this
    ->assertEquals('Symfony\\Component\\HttpFoundation\\JsonResponse', get_class($response));
  $this
    ->assertEquals('{"status":"error","message":"invalid incident (0)."}', $response
    ->getContent());
}