mirror of
https://github.com/elyby/accounts.git
synced 2025-05-31 14:11:46 +05:30
Implemented PHP-CS-Fixer support
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
<?php
|
||||
namespace tests\codeception\common\_support;
|
||||
|
||||
use Codeception\Module;
|
||||
use ReflectionClass;
|
||||
|
||||
trait ProtectedCaller {
|
||||
|
@@ -19,7 +19,8 @@ namespace tests\codeception\common;
|
||||
class UnitTester extends \Codeception\Actor {
|
||||
use _generated\UnitTesterActions;
|
||||
|
||||
/**
|
||||
* Define custom actions here
|
||||
*/
|
||||
/**
|
||||
* Define custom actions here
|
||||
*/
|
||||
|
||||
}
|
||||
|
@@ -79,7 +79,7 @@ class Helper extends Module {
|
||||
return $this->getYii2()->grabComponent($component);
|
||||
}
|
||||
|
||||
private function getYii2() : Yii2 {
|
||||
private function getYii2(): Yii2 {
|
||||
$yii2 = $this->getModule('Yii2');
|
||||
if (!$yii2 instanceof Yii2) {
|
||||
throw new ModuleException($this, 'Yii2 module must be configured');
|
||||
|
@@ -40,13 +40,13 @@ class TestComponent extends Component {
|
||||
* @param string|null $exchangeName
|
||||
* @return \PhpAmqpLib\Message\AMQPMessage[]
|
||||
*/
|
||||
public function getSentMessages(string $exchangeName = null) : array {
|
||||
public function getSentMessages(string $exchangeName = null): array {
|
||||
if ($exchangeName !== null) {
|
||||
return $this->sentMessages[$exchangeName] ?? [];
|
||||
}
|
||||
|
||||
$messages = [];
|
||||
foreach($this->sentMessages as $exchangeGroup) {
|
||||
foreach ($this->sentMessages as $exchangeGroup) {
|
||||
foreach ($exchangeGroup as $message) {
|
||||
$messages[] = $message;
|
||||
}
|
||||
|
@@ -8,6 +8,11 @@ class Queue extends BaseQueue {
|
||||
|
||||
private $messages = [];
|
||||
|
||||
public function __set($name, $value) {
|
||||
// Yii2 components may contains some configuration
|
||||
// But we just ignore it for this mock component
|
||||
}
|
||||
|
||||
public function push($job) {
|
||||
$this->messages[] = $job;
|
||||
}
|
||||
@@ -24,9 +29,4 @@ class Queue extends BaseQueue {
|
||||
// This function is abstract, but will be not called
|
||||
}
|
||||
|
||||
public function __set($name, $value) {
|
||||
// Yii2 components may contains some configuration
|
||||
// But we just ignore it for this mock component
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -3,13 +3,18 @@ namespace tests\codeception\common\unit;
|
||||
|
||||
use Mockery;
|
||||
|
||||
class TestCase extends \Codeception\Test\Unit {
|
||||
class TestCase extends \Codeception\Test\Unit {
|
||||
|
||||
/**
|
||||
* @var \tests\codeception\common\UnitTester
|
||||
*/
|
||||
protected $tester;
|
||||
|
||||
protected function tearDown() {
|
||||
parent::tearDown();
|
||||
Mockery::close();
|
||||
}
|
||||
|
||||
/**
|
||||
* Список фикстур, что будут загружены перед тестом, но после зачистки базы данных
|
||||
*
|
||||
@@ -21,9 +26,4 @@ class TestCase extends \Codeception\Test\Unit {
|
||||
return [];
|
||||
}
|
||||
|
||||
protected function tearDown() {
|
||||
parent::tearDown();
|
||||
Mockery::close();
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -14,17 +14,17 @@ class PrimaryKeyValueBehaviorTest extends TestCase {
|
||||
$model = new DummyModel();
|
||||
/** @var PrimaryKeyValueBehavior|\PHPUnit_Framework_MockObject_MockObject $behavior */
|
||||
$behavior = $this->getMockBuilder(PrimaryKeyValueBehavior::class)
|
||||
->setMethods(['isValueExists'])
|
||||
->setConstructorArgs([[
|
||||
'value' => function() {
|
||||
return 'mock';
|
||||
},
|
||||
]])
|
||||
->getMock();
|
||||
->setMethods(['isValueExists'])
|
||||
->setConstructorArgs([[
|
||||
'value' => function() {
|
||||
return 'mock';
|
||||
},
|
||||
]])
|
||||
->getMock();
|
||||
|
||||
$behavior->expects($this->once())
|
||||
->method('isValueExists')
|
||||
->will($this->returnValue(false));
|
||||
->method('isValueExists')
|
||||
->will($this->returnValue(false));
|
||||
|
||||
$model->attachBehavior('primary-key-value-behavior', $behavior);
|
||||
$behavior->setPrimaryKeyValue();
|
||||
@@ -44,12 +44,12 @@ class PrimaryKeyValueBehaviorTest extends TestCase {
|
||||
->getMock();
|
||||
|
||||
$behavior->expects($this->exactly(3))
|
||||
->method('generateValue')
|
||||
->will($this->onConsecutiveCalls('1', '2', '3'));
|
||||
->method('generateValue')
|
||||
->will($this->onConsecutiveCalls('1', '2', '3'));
|
||||
|
||||
$behavior->expects($this->exactly(3))
|
||||
->method('isValueExists')
|
||||
->will($this->onConsecutiveCalls(true, true, false));
|
||||
->method('isValueExists')
|
||||
->will($this->onConsecutiveCalls(true, true, false));
|
||||
|
||||
$model->attachBehavior('primary-key-value-behavior', $behavior);
|
||||
$behavior->setPrimaryKeyValue();
|
||||
|
@@ -115,7 +115,7 @@ class EmailValidatorTest extends TestCase {
|
||||
* @param string $fieldValue
|
||||
* @return Model
|
||||
*/
|
||||
private function createModel(string $fieldValue) : Model {
|
||||
private function createModel(string $fieldValue): Model {
|
||||
$class = new class extends Model {
|
||||
public $field;
|
||||
};
|
||||
|
@@ -50,21 +50,22 @@ class UsernameValidatorTest extends TestCase {
|
||||
$this->assertNotEquals(['error.username_too_long'], $model->getErrors('field'));
|
||||
}
|
||||
|
||||
// TODO: rewrite this test with @provider usage
|
||||
public function testValidateAttributePattern() {
|
||||
$shouldBeValid = [
|
||||
'русский_ник', 'русский_ник_на_грани!', 'numbers1132', '*__*-Stars-*__*', '1-_.!$%^&*()[]',
|
||||
'[ESP]Эрик', 'Свят_помидор;', 'зроблена_ў_беларусі:)',
|
||||
];
|
||||
foreach($shouldBeValid as $nickname) {
|
||||
foreach ($shouldBeValid as $nickname) {
|
||||
$model = $this->createModel($nickname);
|
||||
$this->validator->validateAttribute($model, 'field');
|
||||
$this->assertNotEquals(['error.username_invalid'], $model->getErrors('field'));
|
||||
}
|
||||
|
||||
$shouldBeInvalid = [
|
||||
'nick@name', 'spaced nick', 'im#hashed', 'quest?ion'
|
||||
'nick@name', 'spaced nick', 'im#hashed', 'quest?ion',
|
||||
];
|
||||
foreach($shouldBeInvalid as $nickname) {
|
||||
foreach ($shouldBeInvalid as $nickname) {
|
||||
$model = $this->createModel($nickname);
|
||||
$this->validator->validateAttribute($model, 'field');
|
||||
$this->assertEquals(['error.username_invalid'], $model->getErrors('field'));
|
||||
@@ -100,7 +101,7 @@ class UsernameValidatorTest extends TestCase {
|
||||
* @param string $fieldValue
|
||||
* @return Model
|
||||
*/
|
||||
private function createModel(string $fieldValue) : Model {
|
||||
private function createModel(string $fieldValue): Model {
|
||||
$class = new class extends Model {
|
||||
public $field;
|
||||
};
|
||||
|
Reference in New Issue
Block a user