Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unify CI and fix phpstan v1.9.0 #1075

Merged
merged 2 commits into from
Nov 3, 2022
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Agile Data is a framework for defining your "business layer" which is separate f
- Agile Data is high-performance, capable of abstracting aggregation logic and shifting it into a capable database persistence (such as SQL) through advanced expressions.
- Agile Data is extensible - field types, persistence types, relations and action types can be extended.

![Build](https://github.com/atk4/data/workflows/Unit%20Testing/badge.svg)
![Build](https://github.com/atk4/data/workflows/Unit/badge.svg)
[![CodeCov](https://codecov.io/gh/atk4/data/branch/develop/graph/badge.svg)](https://codecov.io/gh/atk4/data)
[![GitHub release](https://img.shields.io/github/release/atk4/data.svg)](CHANGELOG.md)
[![Code Climate](https://codeclimate.com/github/atk4/data/badges/gpa.svg)](https://codeclimate.com/github/atk4/data)
Expand Down
4 changes: 2 additions & 2 deletions src/Persistence/Sql/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,10 @@ public static function normalizeDsn($dsn, $user = null, $password = null)
$dsn['dsn'] = str_replace('-', '_', $parsed['scheme']) . ':';
unset($parsed['scheme']);
foreach ($parsed as $k => $v) {
if ($k === 'pass') { // @phpstan-ignore-line phpstan bug
if ($k === 'pass') {
unset($parsed[$k]);
$k = 'password';
} elseif ($k === 'path') { // @phpstan-ignore-line phpstan bug
} elseif ($k === 'path') {
unset($parsed[$k]);
$k = 'dbname';
$v = preg_replace('~^/~', '', $v);
Expand Down
2 changes: 1 addition & 1 deletion src/Schema/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ private static function compareExportUnorderedValue($a, $b): int
protected static function assertSameExportUnordered(array $expected, array $actual, string $message = ''): void
{
if (self::compareExportUnorderedValue($expected, $actual) === 0) {
static::assertTrue(true);
static::assertTrue(true); // @phpstan-ignore-line

return;
}
Expand Down
2 changes: 0 additions & 2 deletions tests/BusinessModelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,6 @@ public function testDefaultInit(): void
$m = new Model($p);
$m = $m->createEntity();

static::assertNotNull($m->getField('id'));

$m->set('id', 20);
static::assertSame(20, $m->getId());
}
Expand Down
1 change: 0 additions & 1 deletion tests/ContainsManyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ public function testContainsMany(): void

// now let's add some lines
$l = $i->lines;
static::assertNotNull($l);
$rows = [
1 => [
$l->fieldName()->id => 1,
Expand Down
8 changes: 4 additions & 4 deletions tests/ContainsOneTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function testContainsOne(): void
static::assertSame(Address::class, get_class($i->getModel()->addr));

// check do we have address set
static::assertNull($i->addr);
static::assertNull($i->addr); // @phpstan-ignore-line
$a = $i->getModel()->addr->createEntity();
$a->containedInEntity = $i;

Expand Down Expand Up @@ -150,12 +150,12 @@ public function testContainsOne(): void
// so far so good. now let's try to delete door_code
$i->addr->door_code->delete();
static::assertNull($i->addr->get($i->addr->fieldName()->door_code));
static::assertNull($i->addr->door_code);
static::assertNull($i->addr->door_code); // @phpstan-ignore-line

// and now delete address
$i->addr->delete();
static::assertNull($i->get($i->fieldName()->addr));
static::assertNull($i->addr);
static::assertNull($i->addr); // @phpstan-ignore-line
}

/**
Expand All @@ -167,7 +167,7 @@ public function testContainsOneWhenChangeModelFields(): void
$i = $i->loadBy($i->fieldName()->ref_no, 'A1');

// with address
static::assertNull($i->addr);
static::assertNull($i->addr); // @phpstan-ignore-line
$a = $i->getModel()->addr->createEntity();
$a->containedInEntity = $i;
$a->setMulti($row = [
Expand Down
2 changes: 0 additions & 2 deletions tests/Field/PasswordFieldTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,9 @@ public function testGeneratePassword(): void
$field = new PasswordField();

$pwd = $field->generatePassword();
static::assertIsString($pwd);
static::assertSame(8, strlen($pwd));

$pwd = $field->generatePassword(50);
static::assertIsString($pwd);
static::assertSame(50, strlen($pwd));
}
}
2 changes: 1 addition & 1 deletion tests/Persistence/Sql/ConnectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public function testConnectionRegistry(): void
static::assertSame(DummyConnection::class, Connection::resolveConnectionClass('dummy'));
try {
Connection::resolveConnectionClass('dummy2');
static::assertFalse(true);
static::assertFalse(true); // @phpstan-ignore-line
} catch (\Exception $e) {
}

Expand Down
16 changes: 4 additions & 12 deletions tests/UserActionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,25 +185,17 @@ public function testDisabled2(): void
$client = new UaClient($this->pers);
$client = $client->load(1);

$client->getUserAction('sendReminder')->enabled = function (Model $m) {
return false;
$client->getUserAction('sendReminder')->enabled = function (UaClient $m) {
return true;
};

$this->expectExceptionMessage('disabled');
$client->getUserAction('sendReminder')->execute();
}

public function testDisabled3(): void
{
$client = new UaClient($this->pers);
$client = $client->load(1);

$client->getUserAction('sendReminder')->enabled = function (UaClient $m) {
return true;
return false;
};

$this->expectExceptionMessage('disabled');
$client->getUserAction('sendReminder')->execute();
static::assertTrue(true); // no exception
}

public function testFields(): void
Expand Down
2 changes: 1 addition & 1 deletion tests/ValidationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public function testValidate1(): void
$m->set('name', 'john');
$m->set('domain', 'gmail.com');
$m->save();
static::assertTrue(true); // no exception
static::assertSame('john', $m->get('name'));
}

public function testValidate2(): void
Expand Down