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

Fix "dynamic call to static method" phpstan error in tests #612

Merged
merged 3 commits into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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: 2 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
'declare_strict_types' => true,
'void_return' => true,
'native_function_invocation' => ['include' => ['@compiler_optimized'], 'scope' => 'namespaced'],
'php_unit_test_case_static_method_calls' => ['call_type' => 'self'],
'php_unit_strict' => true,
];

$config = new PhpCsFixer\Config();
Expand Down
2 changes: 0 additions & 2 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,3 @@ parameters:
paths:
- src
- tests
ignoreErrors:
- '#Dynamic call to static method PHPUnit\\Framework\\.*#'
10 changes: 5 additions & 5 deletions tests/Contracts/CancelTasksQueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,24 @@ public function testSetTypes(): void
{
$data = (new CancelTasksQuery())->setTypes(['abc', 'xyz']);

$this->assertEquals(['types' => 'abc,xyz'], $data->toArray());
self::assertSame(['types' => 'abc,xyz'], $data->toArray());
}

public function testSetAnyDateFilter(): void
{
$date = new \DateTime();
$data = (new CancelTasksQuery())->setBeforeEnqueuedAt($date);

$this->assertEquals(['beforeEnqueuedAt' => $date->format(\DateTime::RFC3339)], $data->toArray());
self::assertSame(['beforeEnqueuedAt' => $date->format(\DateTime::RFC3339)], $data->toArray());
}

public function testToArrayWithDifferentSets(): void
{
$data = (new CancelTasksQuery())->setUids([1, 2, 3])->setStatuses(['enqueued']);

$this->assertEquals([
'uids' => '1,2,3', 'statuses' => 'enqueued',
],
self::assertSame([
'statuses' => 'enqueued', 'uids' => '1,2,3',
],
$data->toArray()
);
}
aivchen marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
8 changes: 4 additions & 4 deletions tests/Contracts/DeleteTasksQueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,23 @@ public function testSetTypes(): void
{
$data = (new DeleteTasksQuery())->setTypes(['abc', 'xyz']);

$this->assertEquals(['types' => 'abc,xyz'], $data->toArray());
self::assertSame(['types' => 'abc,xyz'], $data->toArray());
}

public function testSetAnyDateFilter(): void
{
$date = new \DateTime();
$data = (new DeleteTasksQuery())->setCanceledBy([null])->setBeforeEnqueuedAt($date);

$this->assertEquals(['beforeEnqueuedAt' => $date->format(\DateTime::RFC3339)], $data->toArray());
self::assertSame(['beforeEnqueuedAt' => $date->format(\DateTime::RFC3339)], $data->toArray());
}

public function testToArrayWithDifferentSets(): void
{
$data = (new DeleteTasksQuery())->setCanceledBy([1, 2])->setStatuses(['enqueued']);

$this->assertEquals([
'canceledBy' => '1,2', 'statuses' => 'enqueued',
self::assertSame([
'statuses' => 'enqueued', 'canceledBy' => '1,2',
], $data->toArray()
);
aivchen marked this conversation as resolved.
Show resolved Hide resolved
}
Expand Down
8 changes: 4 additions & 4 deletions tests/Contracts/DocumentsQueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,27 @@ public function testSetFields(): void
{
$data = (new DocumentsQuery())->setLimit(10)->setFields(['abc', 'xyz']);

$this->assertEquals(['limit' => 10, 'fields' => 'abc,xyz'], $data->toArray());
self::assertSame(['limit' => 10, 'fields' => 'abc,xyz'], $data->toArray());
}

public function testToArrayWithoutSetFields(): void
{
$data = (new DocumentsQuery())->setLimit(10);

$this->assertEquals(['limit' => 10], $data->toArray());
self::assertSame(['limit' => 10], $data->toArray());
}

public function testToArrayWithoutSetOffset(): void
{
$data = (new DocumentsQuery())->setOffset(10);

$this->assertEquals(['offset' => 10], $data->toArray());
self::assertSame(['offset' => 10], $data->toArray());
}

public function testToArrayWithZeros(): void
{
$data = (new DocumentsQuery())->setLimit(0)->setOffset(0);

$this->assertEquals(['limit' => 0, 'offset' => 0], $data->toArray());
self::assertSame(['offset' => 0, 'limit' => 0], $data->toArray());
}
}
8 changes: 4 additions & 4 deletions tests/Contracts/IndexesQueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,27 @@ public function testToArrayWithSetOffsetAndSetLimit(): void
{
$data = (new IndexesQuery())->setLimit(10)->setOffset(18);

$this->assertEquals(['limit' => 10, 'offset' => 18], $data->toArray());
self::assertSame(['offset' => 18, 'limit' => 10], $data->toArray());
}

public function testToArrayWithSetOffset(): void
{
$data = (new IndexesQuery())->setOffset(5);

$this->assertEquals(['offset' => 5], $data->toArray());
self::assertSame(['offset' => 5], $data->toArray());
}

public function testToArrayWithoutSet(): void
{
$data = new IndexesQuery();

$this->assertEmpty($data->toArray());
self::assertEmpty($data->toArray());
}

public function testToArrayWithZeros(): void
{
$data = (new IndexesQuery())->setLimit(0)->setOffset(0);

$this->assertEquals(['limit' => 0, 'offset' => 0], $data->toArray());
self::assertSame(['offset' => 0, 'limit' => 0], $data->toArray());
}
}
8 changes: 4 additions & 4 deletions tests/Contracts/KeysQueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,27 @@ public function testToArrayWithSetOffsetAndSetLimit(): void
{
$data = (new KeysQuery())->setLimit(10)->setOffset(18);

$this->assertEquals(['limit' => 10, 'offset' => 18], $data->toArray());
self::assertSame(['offset' => 18, 'limit' => 10], $data->toArray());
}

public function testToArrayWithSetOffset(): void
{
$data = (new KeysQuery())->setOffset(5);

$this->assertEquals(['offset' => 5], $data->toArray());
self::assertSame(['offset' => 5], $data->toArray());
}

public function testToArrayWithoutSet(): void
{
$data = new KeysQuery();

$this->assertEmpty($data->toArray());
self::assertEmpty($data->toArray());
}

public function testToArrayWithZeros(): void
{
$data = (new KeysQuery())->setLimit(0)->setOffset(0);

$this->assertEquals(['limit' => 0, 'offset' => 0], $data->toArray());
self::assertSame(['offset' => 0, 'limit' => 0], $data->toArray());
}
}
12 changes: 6 additions & 6 deletions tests/Contracts/TasksQueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,37 +13,37 @@ public function testSetTypes(): void
{
$data = (new TasksQuery())->setTypes(['abc', 'xyz']);

$this->assertEquals(['types' => 'abc,xyz'], $data->toArray());
self::assertSame(['types' => 'abc,xyz'], $data->toArray());
}

public function testSetAnyDateFilter(): void
{
$date = new \DateTime();
$data = (new TasksQuery())->setBeforeEnqueuedAt($date);

$this->assertEquals($data->toArray(), ['beforeEnqueuedAt' => $date->format(\DateTime::RFC3339)]);
self::assertSame($data->toArray(), ['beforeEnqueuedAt' => $date->format(\DateTime::RFC3339)]);
aivchen marked this conversation as resolved.
Show resolved Hide resolved
}

public function testToArrayWithSetLimit(): void
{
$data = (new TasksQuery())->setLimit(10);

$this->assertEquals(['limit' => 10], $data->toArray());
self::assertSame(['limit' => 10], $data->toArray());
}

public function testToArrayWithSetLimitWithZero(): void
{
$data = (new TasksQuery())->setLimit(0);

$this->assertEquals(['limit' => 0], $data->toArray());
self::assertSame(['limit' => 0], $data->toArray());
}

public function testToArrayWithDifferentSets(): void
{
$data = (new TasksQuery())->setFrom(10)->setLimit(9)->setCanceledBy([1, 4])->setStatuses(['enqueued']);

$this->assertEquals([
'limit' => 9, 'from' => 10, 'statuses' => 'enqueued', 'canceledBy' => '1,4',
self::assertSame([
'statuses' => 'enqueued', 'from' => 10, 'limit' => 9, 'canceledBy' => '1,4',
], $data->toArray());
aivchen marked this conversation as resolved.
Show resolved Hide resolved
}
}
Loading