Skip to content

Commit

Permalink
fix stan
Browse files Browse the repository at this point in the history
  • Loading branch information
mvorisek committed Nov 3, 2022
1 parent 3a7b99d commit 1e94070
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 26 deletions.
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

0 comments on commit 1e94070

Please sign in to comment.