Skip to content

Commit 7cd7539

Browse files
committed
finished static analysis tests
1 parent b9aadc8 commit 7cd7539

File tree

3 files changed

+34
-16
lines changed

3 files changed

+34
-16
lines changed

psalm.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@
4747
<directory name="src"/>
4848
</errorLevel>
4949
</UnusedForeachValue>
50+
<MissingConstructor>
51+
<errorLevel type="suppress">
52+
<directory name="tests"/>
53+
</errorLevel>
54+
</MissingConstructor>
5055
</issueHandlers>
5156
<stubs>
5257
<file name="./vendor/vimeo/psalm/stubs/ext-ds.phpstub"/>

tests/Integration/OGMFormatterIntegrationTest.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,8 +255,6 @@ public function testLocalDateTime(string $alias): void
255255
$result = $this->client->run('RETURN localdatetime() as local', [], $alias)->first()->get('local');
256256

257257
self::assertInstanceOf(LocalDateTime::class, $result);
258-
self::assertIsInt($result->seconds);
259-
self::assertIsInt($result->nanoseconds);
260258
$date = $result->toDateTime();
261259
self::assertEquals($result->getSeconds(), $date->getTimestamp());
262260
}

tests/Unit/CypherTypeTest.php

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,40 @@
1313

1414
namespace Laudis\Neo4j\Tests\Unit;
1515

16-
use ArrayIterator;
1716
use BadMethodCallException;
1817
use InvalidArgumentException;
1918
use function json_encode;
2019
use JsonException;
2120
use Laudis\Neo4j\Types\AbstractCypherObject;
2221
use PHPUnit\Framework\TestCase;
2322

23+
/**
24+
* @extends AbstractCypherObject<string, mixed>
25+
* @psalm-immutable
26+
*/
27+
final class BogusCypherObject extends AbstractCypherObject
28+
{
29+
public function toArray(): array
30+
{
31+
return [];
32+
}
33+
}
34+
35+
/**
36+
* @extends AbstractCypherObject<string, mixed>
37+
* @psalm-immutable
38+
*/
39+
final class BogusCypherObjectFilled extends AbstractCypherObject
40+
{
41+
public function toArray(): array
42+
{
43+
return [
44+
'a' => 'b',
45+
'c' => 'd',
46+
];
47+
}
48+
}
49+
2450
final class CypherTypeTest extends TestCase
2551
{
2652
/**
@@ -30,12 +56,7 @@ final class CypherTypeTest extends TestCase
3056
*/
3157
public function testEmpty(): void
3258
{
33-
$empty = new class() extends AbstractCypherObject {
34-
public function getIterator()
35-
{
36-
return new ArrayIterator([]);
37-
}
38-
};
59+
$empty = new BogusCypherObject();
3960

4061
self::assertEquals('[]', json_encode($empty, JSON_THROW_ON_ERROR));
4162
self::assertFalse(isset($empty[0]));
@@ -73,13 +94,7 @@ public function getIterator()
7394
*/
7495
public function testFilled(): void
7596
{
76-
$filled = new class() extends AbstractCypherObject {
77-
public function getIterator()
78-
{
79-
yield 'a' => 'b';
80-
yield 'c' => 'd';
81-
}
82-
};
97+
$filled = new BogusCypherObjectFilled();
8398

8499
self::assertEquals('{"a":"b","c":"d"}', json_encode($filled, JSON_THROW_ON_ERROR));
85100

0 commit comments

Comments
 (0)