Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,4 @@ Dockerfile linguist-detectable=false
/Dockerfile export-ignore
/docker-compose.yml export-ignore
/entrypoint.sh export-ignore
/phpcs.xml export-ignore
/phpunit.xml export-ignore
2 changes: 1 addition & 1 deletion .php-cs-fixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
'no_empty_comment' => true,
'no_trailing_whitespace_in_comment' => true,
'single_line_comment_spacing' => true,
'single_line_comment_style' => ['comment_types' => ['asterisk', 'hash']]
'single_line_comment_style' => ['comment_types' => ['hash']]
];

$constantNotationRules = [
Expand Down
8 changes: 4 additions & 4 deletions tests/ErrorWarningTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ public function testErrorField(): void

$implem->addErrorField('field 2', 'invalid 11');
static::assertTrue($implem->hasErrorFields());
static::assertSame(['field 1' => ['invalid 1', 'invalid 2'], 'field 2' => ['invalid 11']], $implem->getErrorFields()); // phpcs:ignore
static::assertSame(['field 1' => ['invalid 1', 'invalid 2'], 'field 2' => ['invalid 11']], $implem->getErrorFields());

$implem->addErrorField('field 2', 'invalid 22');
static::assertTrue($implem->hasErrorFields());
static::assertSame(['field 1' => ['invalid 1', 'invalid 2'], 'field 2' => ['invalid 11', 'invalid 22']], $implem->getErrorFields()); // phpcs:ignore
static::assertSame(['field 1' => ['invalid 1', 'invalid 2'], 'field 2' => ['invalid 11', 'invalid 22']], $implem->getErrorFields());

$implem->resetErrorField('field 2');
static::assertTrue($implem->hasErrorFields());
Expand All @@ -94,11 +94,11 @@ public function testWarningField(): void

$implem->addWarningField('field 2', 'invalid 11');
static::assertTrue($implem->hasWarningFields());
static::assertSame(['field 1' => ['invalid 1', 'invalid 2'], 'field 2' => ['invalid 11']], $implem->getWarningFields()); // phpcs:ignore
static::assertSame(['field 1' => ['invalid 1', 'invalid 2'], 'field 2' => ['invalid 11']], $implem->getWarningFields());

$implem->addWarningField('field 2', 'invalid 22');
static::assertTrue($implem->hasWarningFields());
static::assertSame(['field 1' => ['invalid 1', 'invalid 2'], 'field 2' => ['invalid 11', 'invalid 22']], $implem->getWarningFields()); // phpcs:ignore
static::assertSame(['field 1' => ['invalid 1', 'invalid 2'], 'field 2' => ['invalid 11', 'invalid 22']], $implem->getWarningFields());

$implem->resetWarningField('field 2');
static::assertTrue($implem->hasWarningFields());
Expand Down
10 changes: 3 additions & 7 deletions tests/FieldTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ class FieldTest extends TestCase
public function testFieldExceptionInvalidType(): void
{
$this->expectException(FieldException::class);
$this->expectExceptionMessage('Incorrect Type. Valid type: int, float, char, varchar, text, date, datetime, time, timestamp, year, enum:v1,v2'); // phpcs:ignore
$this->expectExceptionMessage('Incorrect Type. Valid type: int, float, char, varchar, text, date, datetime, time, timestamp, year, enum:v1,v2');

new Field('invalid');
}

public function testFieldExceptionInvalidRule(): void
{
$this->expectException(FieldException::class);
$this->expectExceptionMessage('Incorrect Rule. Valid rule: pk, fk, unsigned, email, not_null, max, min, range, max:int, min:int, range:int,int'); // phpcs:ignore
$this->expectExceptionMessage('Incorrect Rule. Valid rule: pk, fk, unsigned, email, not_null, max, min, range, max:int, min:int, range:int,int');

new Field('int', ['invalid']);
}
Expand Down Expand Up @@ -71,8 +71,6 @@ public function testFieldDefault(): void

public static function provideFieldFormatDataCases(): iterable
{
// phpcs:disable

// char
yield 'char' => [
'fieldType' => 'char',
Expand Down Expand Up @@ -1606,15 +1604,13 @@ public static function provideFieldFormatDataCases(): iterable
'expected' => [null, null, FieldException::class, '-1', '10', '50.5', ''],
'message' => [null, null, 'invalid azerty value', null, null, null, null]
];

// phpcs:enable
}

// endregion

/** @throws FieldException */
#[DataProvider('provideFieldFormatDataCases')]
public function testFieldFormat(string $fieldType, array $rules, $default, array $input, array $expected, array $message): void // phpcs:ignore
public function testFieldFormat(string $fieldType, array $rules, $default, array $input, array $expected, array $message): void
{
$rule = new Field($fieldType, $rules, $default);
for ($i = 0, $max = \count($input); $i < $max; ++$i) {
Expand Down
28 changes: 13 additions & 15 deletions tests/ModelTest.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
<?php

/**
* @noinspection SqlDialectInspection
*/
/** @noinspection SqlDialectInspection */

declare(strict_types=1);

Expand Down Expand Up @@ -208,9 +206,9 @@ class ModelTest extends TestCase
UNIQUE KEY `external_id_UNIQUE` (`external_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
EOD,
"INSERT INTO crud_table VALUES (1, 'first', '{{DATE_START}}', null, '00:00:00', null, 'yes', null, null, null)", // phpcs:ignore
"INSERT INTO crud_table VALUES (2, 'secon', '2018-08-07 20:06:23', null, '00:00:00', null, 'yes', null, null, null)", // phpcs:ignore
"INSERT INTO crud_table VALUES (3, 'third', '2018-08-07 20:06:23', null, '00:00:00', null, 'yes', null, null, null)", // phpcs:ignore
"INSERT INTO crud_table VALUES (1, 'first', '{{DATE_START}}', null, '00:00:00', null, 'yes', null, null, null)",
"INSERT INTO crud_table VALUES (2, 'secon', '2018-08-07 20:06:23', null, '00:00:00', null, 'yes', null, null, null)",
"INSERT INTO crud_table VALUES (3, 'third', '2018-08-07 20:06:23', null, '00:00:00', null, 'yes', null, null, null)",
],
],
'pgsql' => [
Expand Down Expand Up @@ -249,9 +247,9 @@ class ModelTest extends TestCase
external_id int
);
EOD,
"INSERT INTO crud_table VALUES (1, 'first', '{{DATE_START}}', null, null, null, 'yes', null, null, null)", // phpcs:ignore
"INSERT INTO crud_table VALUES (2, 'secon', '2018-08-07 20:06:23', null, null, null, 'yes', null, null, null)", // phpcs:ignore
"INSERT INTO crud_table VALUES (3, 'third', '2018-08-07 20:06:23', null, null, null, 'yes', null, null, null)", // phpcs:ignore
"INSERT INTO crud_table VALUES (1, 'first', '{{DATE_START}}', null, null, null, 'yes', null, null, null)",
"INSERT INTO crud_table VALUES (2, 'secon', '2018-08-07 20:06:23', null, null, null, 'yes', null, null, null)",
"INSERT INTO crud_table VALUES (3, 'third', '2018-08-07 20:06:23', null, null, null, 'yes', null, null, null)",
],
],
'sqlite' => [
Expand Down Expand Up @@ -290,9 +288,9 @@ class ModelTest extends TestCase
);
EOD,
'create unique index crud_table_external_id_uindex on crud_table (external_id);',
"INSERT INTO crud_table VALUES (1, 'first', '{{DATE_START}}', null, '00:00:00', null, 'yes', null, null, null)", // phpcs:ignore
"INSERT INTO crud_table VALUES (2, 'secon', '2018-08-07 20:06:23', null, '00:00:00', null, 'yes', null, null, null)", // phpcs:ignore
"INSERT INTO crud_table VALUES (3, 'third', '2018-08-07 20:06:23', null, '00:00:00', null, 'yes', null, null, null)", // phpcs:ignore
"INSERT INTO crud_table VALUES (1, 'first', '{{DATE_START}}', null, '00:00:00', null, 'yes', null, null, null)",
"INSERT INTO crud_table VALUES (2, 'secon', '2018-08-07 20:06:23', null, '00:00:00', null, 'yes', null, null, null)",
"INSERT INTO crud_table VALUES (3, 'third', '2018-08-07 20:06:23', null, '00:00:00', null, 'yes', null, null, null)",
],
],
];
Expand All @@ -314,7 +312,7 @@ protected function setUp(): void

if ($configurator->getDriver() === 'pgsql') {
$postgresHost = \getenv('POSTGRES_HOST', true);
$configurator->setHost(($postgresHost !== false) ? $postgresHost : $this->sgbds[$k]['parameters']['host']); // phpcs:ignore
$configurator->setHost(($postgresHost !== false) ? $postgresHost : $this->sgbds[$k]['parameters']['host']);
}

$this->sgbds[$k]['db'] = new Database($configurator);
Expand Down Expand Up @@ -820,7 +818,7 @@ public function testUpdate(string $sgbd): void
}

$implem = new ImplementModel($this->sgbds[$sgbd]['db']);
$implem->update(['title' => 'youpie', 'param_to_remove' => 'this will be remove in parametersToRemove function'], 1); // phpcs:ignore
$implem->update(['title' => 'youpie', 'param_to_remove' => 'this will be remove in parametersToRemove function'], 1);

$row = $implem->one(1);
static::assertSame('youpi', $row['title']);
Expand Down Expand Up @@ -958,7 +956,7 @@ public function testCallbacks(string $sgbd): void

$implem->addBeforeCreate('b', static function ($sql, $params) {
static::assertSame('toto', $sql);
$sql = 'INSERT INTO crud_table (`title`,`date_start`, `year_start`) VALUES (:title,:date_start, :year_start)'; // phpcs:ignore
$sql = 'INSERT INTO crud_table (`title`,`date_start`, `year_start`) VALUES (:title,:date_start, :year_start)';
$params['year_start'] = 1956;

static::assertSame('az', $params['title']);
Expand Down