mirror of
https://github.com/elyby/accounts.git
synced 2025-05-31 14:11:46 +05:30
Fix tests
This commit is contained in:
@@ -1,10 +1,6 @@
|
||||
<?php
|
||||
|
||||
Codeception\PHPUnit\Init::init();
|
||||
|
||||
defined('YII_DEBUG') || define('YII_DEBUG', true);
|
||||
defined('YII_ENV') || define('YII_ENV', 'test');
|
||||
|
||||
defined('YII_APP_BASE_PATH') || define('YII_APP_BASE_PATH', __DIR__ . '/../../');
|
||||
|
||||
require_once YII_APP_BASE_PATH . '/vendor/autoload.php';
|
||||
|
@@ -8,8 +8,6 @@ use api\tests\unit\TestCase;
|
||||
use GuzzleHttp\ClientInterface;
|
||||
use GuzzleHttp\Exception\ConnectException;
|
||||
use GuzzleHttp\Psr7\Response;
|
||||
use phpmock\mockery\PHPMockery;
|
||||
use ReflectionClass;
|
||||
|
||||
class ValidatorTest extends TestCase {
|
||||
|
||||
@@ -44,7 +42,7 @@ class ValidatorTest extends TestCase {
|
||||
],
|
||||
])))
|
||||
);
|
||||
PHPMockery::mock($this->getClassNamespace(Validator::class), 'sleep')->once();
|
||||
$this->getFunctionMock(Validator::class, 'sleep')->expects($this->once());
|
||||
|
||||
$validator = new Validator($mockClient);
|
||||
$this->assertTrue($validator->validate('12341234', $error));
|
||||
@@ -54,7 +52,7 @@ class ValidatorTest extends TestCase {
|
||||
public function testValidateWithHugeNetworkTroubles() {
|
||||
$mockClient = $this->createMock(ClientInterface::class);
|
||||
$mockClient->expects($this->exactly(3))->method('request')->willThrowException($this->createMock(ConnectException::class));
|
||||
PHPMockery::mock($this->getClassNamespace(Validator::class), 'sleep')->times(2);
|
||||
$this->getFunctionMock(Validator::class, 'sleep')->expects($this->exactly(2));
|
||||
|
||||
$validator = new Validator($mockClient);
|
||||
$this->expectException(ConnectException::class);
|
||||
@@ -71,8 +69,4 @@ class ValidatorTest extends TestCase {
|
||||
$this->assertNull($error);
|
||||
}
|
||||
|
||||
private function getClassNamespace(string $className): string {
|
||||
return (new ReflectionClass($className))->getNamespaceName();
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user