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
24 changes: 13 additions & 11 deletions tests/system/Models/DataConverterModelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function testFindAsArray(): void

$user = $this->model->find($id);

$this->assertIsInt($user['id']);
$this->assertIsInt($user['id']); // @phpstan-ignore offsetAccess.notFound
$this->assertInstanceOf(Time::class, $user['created_at']);
$this->assertSame('John Smith', $user['name']);
// `name` is cast by custom CastBase64 handler.
Expand Down Expand Up @@ -128,9 +128,9 @@ public function testFindAllAsArray(): void

$users = $this->model->findAll();

$this->assertIsInt($users[0]['id']);
$this->assertIsInt($users[0]['id']); // @phpstan-ignore offsetAccess.notFound
$this->assertInstanceOf(Time::class, $users[0]['created_at']);
$this->assertIsInt($users[1]['id']);
$this->assertIsInt($users[1]['id']); // @phpstan-ignore offsetAccess.notFound
$this->assertInstanceOf(Time::class, $users[1]['created_at']);
}

Expand Down Expand Up @@ -208,7 +208,7 @@ public function testFirstAsArray(): void

$user = $this->model->first();

$this->assertIsInt($user['id']);
$this->assertIsInt($user['id']); // @phpstan-ignore offsetAccess.notFound
$this->assertInstanceOf(Time::class, $user['created_at']);
}

Expand Down Expand Up @@ -264,7 +264,8 @@ public function testInsertArray(): void
$id = $this->model->insert($data, true);

$user = $this->model->find($id);
$this->assertSame(['[email protected]'], $user['email']);

$this->assertSame(['[email protected]'], $user['email']); // @phpstan-ignore offsetAccess.notFound
}

public function testInsertObject(): void
Expand All @@ -279,7 +280,8 @@ public function testInsertObject(): void
$id = $this->model->insert($data, true);

$user = $this->model->find($id);
$this->assertSame(['[email protected]'], $user['email']);

$this->assertSame(['[email protected]'], $user['email']); // @phpstan-ignore offsetAccess.notFound
}

public function testUpdateArray(): void
Expand All @@ -288,14 +290,14 @@ public function testUpdateArray(): void
$user = $this->model->find($id);

$user['email'][] = '[email protected]';
$this->model->update($user['id'], $user);
$this->model->update($user['id'], $user); // @phpstan-ignore offsetAccess.notFound

$user = $this->model->find($id);

$this->assertSame([
'[email protected]',
'[email protected]',
], $user['email']);
], $user['email']); // @phpstan-ignore offsetAccess.notFound
}

public function testUpdateObject(): void
Expand All @@ -311,7 +313,7 @@ public function testUpdateObject(): void
$this->assertSame([
'[email protected]',
'[email protected]',
], $user['email']);
], $user['email']); // @phpstan-ignore offsetAccess.notFound
}

public function testUpdateCustomObject(): void
Expand Down Expand Up @@ -363,7 +365,7 @@ public function testSaveArray(): void
$this->assertSame([
'[email protected]',
'[email protected]',
], $user['email']);
], $user['email']); // @phpstan-ignore offsetAccess.notFound
}

public function testSaveObject(): void
Expand All @@ -379,7 +381,7 @@ public function testSaveObject(): void
$this->assertSame([
'[email protected]',
'[email protected]',
], $user['email']);
], $user['email']); // @phpstan-ignore offsetAccess.notFound
}

public function testSaveCustomObject(): void
Expand Down
28 changes: 20 additions & 8 deletions tests/system/Models/TimestampModelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,12 @@ public function testDoNotAllowDatesInsertArrayWithoutDatesSetsTimestamp(): void
$user = $this->model->find($id);

$expected = '2023-11-25 12:00:00';

if ($this->db->DBDriver === 'SQLSRV') {
$expected .= '.000';
}
$this->assertSame($expected, $user['created_at']);

$this->assertSame($expected, $user['created_at']); // @phpstan-ignore offsetAccess.notFound
$this->assertSame($expected, $user['updated_at']);
}

Expand All @@ -116,10 +118,12 @@ public function testDoNotAllowDatesInsertArrayWithDatesSetsTimestamp(): void
$user = $this->model->find($id);

$expected = '2023-11-25 12:00:00';

if ($this->db->DBDriver === 'SQLSRV') {
$expected .= '.000';
}
$this->assertSame($expected, $user['created_at']);

$this->assertSame($expected, $user['created_at']); // @phpstan-ignore offsetAccess.notFound
$this->assertSame($expected, $user['updated_at']);
}

Expand All @@ -139,15 +143,17 @@ public function testDoNotAllowDatesUpdateArrayUpdatesUpdatedAt(): void
$user = $this->model->find($id);

$user['country'] = 'CA';
$this->model->update($user['id'], $user);
$this->model->update($user['id'], $user); // @phpstan-ignore offsetAccess.notFound

$user = $this->model->find($id);

$expected = '2023-11-25 12:00:00';

if ($this->db->DBDriver === 'SQLSRV') {
$expected .= '.000';
}
$this->assertSame($expected, $user['created_at']);

$this->assertSame($expected, $user['created_at']); // @phpstan-ignore offsetAccess.notFound
$this->assertSame($expected, $user['updated_at']);
}

Expand Down Expand Up @@ -197,10 +203,12 @@ public function testAllowDatesInsertArrayWithoutDatesSetsTimestamp(): void
$user = $this->model->find($id);

$expected = '2023-11-25 12:00:00';

if ($this->db->DBDriver === 'SQLSRV') {
$expected .= '.000';
}
$this->assertSame($expected, $user['created_at']);

$this->assertSame($expected, $user['created_at']); // @phpstan-ignore offsetAccess.notFound
$this->assertSame($expected, $user['updated_at']);
}

Expand All @@ -224,10 +232,12 @@ public function testAllowDatesInsertArrayWithDatesSetsTimestamp(): void
$user = $this->model->find($id);

$expected = '2000-01-01 12:00:00';

if ($this->db->DBDriver === 'SQLSRV') {
$expected .= '.000';
}
$this->assertSame($expected, $user['created_at']);

$this->assertSame($expected, $user['created_at']); // @phpstan-ignore offsetAccess.notFound
$this->assertSame($expected, $user['updated_at']);
}

Expand All @@ -251,15 +261,17 @@ public function testAllowDatesUpdateArrayUpdatesUpdatedAt(): void
$user = $this->model->find($id);

$user['country'] = 'CA';
$this->model->update($user['id'], $user);
$this->model->update($user['id'], $user); // @phpstan-ignore offsetAccess.notFound

$user = $this->model->find($id);

$expected = '2000-01-01 12:00:00';

if ($this->db->DBDriver === 'SQLSRV') {
$expected .= '.000';
}
$this->assertSame($expected, $user['created_at']);

$this->assertSame($expected, $user['created_at']); // @phpstan-ignore offsetAccess.notFound
$this->assertSame($expected, $user['updated_at']);
}

Expand Down
1 change: 0 additions & 1 deletion utils/phpstan-baseline/loader.neon
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ includes:
- notIdentical.alwaysTrue.neon
- nullCoalesce.property.neon
- nullCoalesce.variable.neon
- offsetAccess.notFound.neon
- parameterByRef.unusedType.neon
- property.defaultValue.neon
- property.nonObject.neon
Expand Down
33 changes: 0 additions & 33 deletions utils/phpstan-baseline/offsetAccess.notFound.neon

This file was deleted.

Loading