Exponential 5.x Kernel 7.5.40 Exponential New Stack (Symfony-based) Kernel — PHP Class Reference

IntegrationTestAuthenticator.php
Go to the documentation of this file.
1 <?php
2
7 namespace eZ\Publish\Core\REST\Client\HttpClient\Authentication;
8
9 use eZ\Publish\Core\REST\Client\HttpClient;
10 use eZ\Publish\Core\REST\Client\Sessionable;
11 use eZ\Publish\Core\REST\Common\Message;
12
18 class IntegrationTestAuthenticator implements HttpClient, Sessionable
19 {
25 protected $innerClient;
26
32 protected $userId;
33
39 protected $sessionId;
40
47 public function __construct(HttpClient $innerClient, $userId = 14)
48 {
49 $this->innerClient = $innerClient;
50 $this->userId = $userId;
51 }
52
66 public function request($method, $path, Message $message = null)
67 {
68 $message = $message ?: new Message();
69
70 $message->headers['X-Test-User'] = $this->userId;
71
72 if ($this->sessionId !== null && !isset($message->headers['X-Test-Session'])) {
73 $message->headers['X-Test-Session'] = $this->sessionId;
74 }
75
76 return $this->innerClient->request($method, $path, $message);
77 }
78
84 public function setUserId($userId)
85 {
86 $this->userId = $userId;
87 }
88
94 public function setSession($id)
95 {
96 $this->sessionId = $id;
97 }
98 }
eZ\Publish\Core\REST\Client\HttpClient\Authentication\IntegrationTestAuthenticator
Authenticator used in integration tests.
Definition: IntegrationTestAuthenticator.php:19
eZ\Publish\Core\REST\Client\HttpClient\Authentication\IntegrationTestAuthenticator\$innerClient
$innerClient
Definition: IntegrationTestAuthenticator.php:25
eZ\Publish\Core\REST\Client\HttpClient\Authentication\IntegrationTestAuthenticator\$userId
$userId
Definition: IntegrationTestAuthenticator.php:32
eZ\Publish\Core\REST\Client\HttpClient\Authentication\IntegrationTestAuthenticator\$sessionId
$sessionId
Definition: IntegrationTestAuthenticator.php:39
eZ\Publish\Core\REST\Client\HttpClient\Authentication\IntegrationTestAuthenticator\setUserId
setUserId($userId)
Sets the user ID submitted to the server.
Definition: IntegrationTestAuthenticator.php:84
eZ\Publish\Core\REST\Client\HttpClient\Authentication\IntegrationTestAuthenticator\setSession
setSession($id)
Set the session ID to use.
Definition: IntegrationTestAuthenticator.php:94
eZ\Publish\Core\REST\Client\HttpClient\Authentication\IntegrationTestAuthenticator\__construct
__construct(HttpClient $innerClient, $userId=14)
Creates a new Integration Test Authenticator.
Definition: IntegrationTestAuthenticator.php:47
eZ\Publish\Core\REST\Client\HttpClient\Authentication\IntegrationTestAuthenticator\request
request($method, $path, Message $message=null)
Execute a HTTP request to the remote server.
Definition: IntegrationTestAuthenticator.php:66
eZ\Publish\Core\REST\Common\Message
Simple response struct.
Definition: Core/REST/Common/Message.php:13
eZ\Publish\Core\REST\Client\HttpClient
Interface for Http Client implementations.
Definition: REST/Client/HttpClient.php:15
eZ\Publish\Core\REST\Client\Sessionable
Implementation of the \eZ\Publish\API\Repository\SectionService interface.
Definition: Sessionable.php:16
eZ\Publish\Core\REST\Client\HttpClient\Authentication
Definition: BasicAuth.php:7
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.