You are here

public function TestController::mockPage in Localization client 8

Mock page for returning a mock XML-RPC response as if this was a server.

Stores the request value for testing purposes.

Return value

\Symfony\Component\HttpFoundation\Response

1 string reference to 'TestController::mockPage'
l10n_client_test.routing.yml in l10n_client_test/l10n_client_test.routing.yml
l10n_client_test/l10n_client_test.routing.yml

File

l10n_client_test/src/Controller/TestController.php, line 20

Class

TestController
Returns responses for comment module administrative routes.

Namespace

Drupal\l10n_client_test\Controller

Code

public function mockPage() {

  // @todo using state may not be good for testing from the test itself.
  $this
    ->state()
    ->set('l10n_client_test_mock_request', file_get_contents('php://input'));
  $response = Response::create('<?xml version="1.0"?>
<methodResponse>
  <params>
  <param>
    <value><struct>
  <member><name>status</name><value><boolean>1</boolean></value></member>
  <member><name>sid</name><value><string>387</string></value></member>
</struct></value>
  </param>
  </params>
</methodResponse>', 200)
    ->setSharedMaxAge(300);
  $response->headers
    ->set('Content-Type', 'application/xml');
  return $response;
}