diff --git a/src/Api/AtolClient.php b/src/Api/AtolClient.php index 9b63445..6bae018 100644 --- a/src/Api/AtolClient.php +++ b/src/Api/AtolClient.php @@ -17,12 +17,11 @@ use AtolOnline\Exceptions\{ EmptyLoginException, EmptyPasswordException, TooLongLoginException, - TooLongPasswordException -}; + TooLongPasswordException}; +use AtolOnline\TestEnvParams; use GuzzleHttp\{ Client, - Exception\GuzzleException -}; + Exception\GuzzleException}; use JetBrains\PhpStorm\Pure; /** @@ -78,8 +77,7 @@ abstract class AtolClient ?string $login = null, ?string $password = null, array $config = [] - ) - { + ) { $this->http = new Client( array_merge($config, [ 'http_errors' => $config['http_errors'] ?? false, @@ -149,9 +147,12 @@ abstract class AtolClient * * @return string|null */ + #[Pure] public function getLogin(): ?string { - return $this->login; + return $this->isTestMode() + ? TestEnvParams::FFD105()['login'] + : $this->login; } /** @@ -179,9 +180,12 @@ abstract class AtolClient * * @return string|null */ + #[Pure] public function getPassword(): ?string { - return $this->password; + return $this->isTestMode() + ? TestEnvParams::FFD105()['password'] + : $this->password; } /** @@ -279,7 +283,7 @@ abstract class AtolClient /** * Выполняет авторизацию на сервере АТОЛ * - * Авторизация выолнится только если неизвестен токен + * Авторизация выполнится только если неизвестен токен * * @param string|null $login * @param string|null $password @@ -294,8 +298,8 @@ abstract class AtolClient public function auth(?string $login = null, ?string $password = null): bool { if (empty($this->getToken())) { - $login && $this->setLogin($login); - $password && $this->setPassword($password); + !is_null($login) && $this->setLogin($login); + !is_null($password) && $this->setPassword($password); if ($token = $this->doAuth()) { $this->setToken($token); } diff --git a/tests/AtolOnline/Tests/Api/KktMonitorTest.php b/tests/AtolOnline/Tests/Api/KktMonitorTest.php index 34ccb7f..af0836b 100644 --- a/tests/AtolOnline/Tests/Api/KktMonitorTest.php +++ b/tests/AtolOnline/Tests/Api/KktMonitorTest.php @@ -32,7 +32,7 @@ use GuzzleHttp\Exception\GuzzleException; class KktMonitorTest extends BasicTestCase { /** - * Возвращает объект клиента для тестирования с тестовым API АТОЛ + * Возвращает объект монитора для тестирования с тестовым API АТОЛ * * @return KktMonitor * @throws EmptyLoginException @@ -42,10 +42,9 @@ class KktMonitorTest extends BasicTestCase */ private function newTestClient(): KktMonitor { - $credentials = TestEnvParams::FFD105(); return (new KktMonitor(true)) - ->setLogin($credentials['login']) - ->setPassword($credentials['password']); + ->setLogin(TestEnvParams::FFD105()['login']) + ->setPassword(TestEnvParams::FFD105()['password']); } /**