-
Notifications
You must be signed in to change notification settings - Fork 264
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
PHPLIB-1514 Make data providers static #1404
Conversation
tests/TestCase.php
Outdated
{ | ||
return [123, 3.14, 'foo', true, [], new stdClass(), $this->createMock(Codec::class)]; | ||
return [123, 3.14, 'foo', true, [], new stdClass(), self::createStub(Codec::class)]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Stubs can be created statically, mock cannot.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have to wait for PHPUnit 10 to use this function.
49d35fb
to
21e944e
Compare
Do you want to address the six errors in this CI build first? |
1224055
to
6de7408
Compare
f2cca38
to
5bb47d7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some questions but changes LGTM.
@@ -53,7 +53,7 @@ protected function assertStreamContents(string $expectedContents, $stream): void | |||
* | |||
* @return resource | |||
*/ | |||
protected function createStream(string $data = '') | |||
protected static function createStream(string $data = '') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically not a data provider but there's also no reason this method can't be static 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made it static because It's used in a data provider.
@@ -86,7 +86,7 @@ public function testWriteBytesCalculatesMD5($input, $expectedMD5): void | |||
$this->assertSameDocument(['md5' => $expectedMD5], $fileDocument); | |||
} | |||
|
|||
public function provideInputDataAndExpectedMD5() | |||
public static function provideInputDataAndExpectedMD5() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Expect a conflict with #1398 later.
} | ||
}; | ||
// @fixme: createStub can be called statically in PHPUnit 10 | ||
// $codec = self::createStub(Codec::class); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume once you upgrade the PHPUnit 10, the above anonymous class can be replaced with the single createStub()
call?
Should this be tracked in a sub-task within PHPLIB-1369, or do you plan on addressing it in the main ticket?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* v1.x: (87 commits) Performance: Keep collections and indexes between GridFS tests (#1421) Add final annotations to non-internal Operation classes (#1410) Fix types accepted by $round (#1401) Replace arrayHasKey with assertArrayHasKey in tests (#1403) PHPLIB-1514 Make data providers static (#1404) PHPLIB-1515 Replace assertObjectHasAttribute with assertObjectHasProperty (#1405) Restore Prose22_RangeExplicitEncryptionTest (#1400) Remove Prose22_RangeExplicitEncryptionTest that requires ext-mongodb < 1.20 (#1394) Use `match` instead of `switch` when a simple value is returned (#1393) Remove PHPUnit functions polyfill (#1395) Update branch names for GHA workflows (#1390) PHPLIB-1419 Encode Agg builder objects in Collection methods (#1383) PHPLIB-1420 Integrate query builder for non-aggregation APIs (#1385) Fix optional parameter declared before required parameter (#1384) PHPLIB-1505 Add driver option "builderEncoder" (#1382) Exclude rector.php from the artifact Check generated files are up-to-date Replace composer package mongodb/builder Skip Pedentry method sort for generated files Remove composer constraints already imposed by the main package ...
* v1.x: (90 commits) Merge v1.20 into v1.x (#1447) PHPLIB-1525 Removes dependency to Symfony PHPUnit bridge (#1413) Change deprecated assertObjectHasAttribute to assertObjectHasProperty (#1432) Performance: Keep collections and indexes between GridFS tests (#1421) Add final annotations to non-internal Operation classes (#1410) Fix types accepted by $round (#1401) Replace arrayHasKey with assertArrayHasKey in tests (#1403) PHPLIB-1514 Make data providers static (#1404) PHPLIB-1515 Replace assertObjectHasAttribute with assertObjectHasProperty (#1405) Restore Prose22_RangeExplicitEncryptionTest (#1400) Remove Prose22_RangeExplicitEncryptionTest that requires ext-mongodb < 1.20 (#1394) Use `match` instead of `switch` when a simple value is returned (#1393) Remove PHPUnit functions polyfill (#1395) Update branch names for GHA workflows (#1390) PHPLIB-1419 Encode Agg builder objects in Collection methods (#1383) PHPLIB-1420 Integrate query builder for non-aggregation APIs (#1385) Fix optional parameter declared before required parameter (#1384) PHPLIB-1505 Add driver option "builderEncoder" (#1382) Exclude rector.php from the artifact Check generated files are up-to-date ...
* v1.x: (90 commits) Merge v1.20 into v1.x (#1447) PHPLIB-1525 Removes dependency to Symfony PHPUnit bridge (#1413) Change deprecated assertObjectHasAttribute to assertObjectHasProperty (#1432) Performance: Keep collections and indexes between GridFS tests (#1421) Add final annotations to non-internal Operation classes (#1410) Fix types accepted by $round (#1401) Replace arrayHasKey with assertArrayHasKey in tests (#1403) PHPLIB-1514 Make data providers static (#1404) PHPLIB-1515 Replace assertObjectHasAttribute with assertObjectHasProperty (#1405) Restore Prose22_RangeExplicitEncryptionTest (#1400) Remove Prose22_RangeExplicitEncryptionTest that requires ext-mongodb < 1.20 (#1394) Use `match` instead of `switch` when a simple value is returned (#1393) Remove PHPUnit functions polyfill (#1395) Update branch names for GHA workflows (#1390) PHPLIB-1419 Encode Agg builder objects in Collection methods (#1383) PHPLIB-1420 Integrate query builder for non-aggregation APIs (#1385) Fix optional parameter declared before required parameter (#1384) PHPLIB-1505 Add driver option "builderEncoder" (#1382) Exclude rector.php from the artifact Check generated files are up-to-date ...
* v1.x: (95 commits) PHPLIB-1369 Upgrade to PHPUnit 10 (#1412) Higher phpunit version required (#1463) Fix deprecations in tests (#1458) Deprecate functionality to be removed (#1441) Expect BulkWriteException (#1455) Merge v1.20 into v1.x (#1447) PHPLIB-1525 Removes dependency to Symfony PHPUnit bridge (#1413) Change deprecated assertObjectHasAttribute to assertObjectHasProperty (#1432) Performance: Keep collections and indexes between GridFS tests (#1421) Add final annotations to non-internal Operation classes (#1410) Fix types accepted by $round (#1401) Replace arrayHasKey with assertArrayHasKey in tests (#1403) PHPLIB-1514 Make data providers static (#1404) PHPLIB-1515 Replace assertObjectHasAttribute with assertObjectHasProperty (#1405) Restore Prose22_RangeExplicitEncryptionTest (#1400) Remove Prose22_RangeExplicitEncryptionTest that requires ext-mongodb < 1.20 (#1394) Use `match` instead of `switch` when a simple value is returned (#1393) Remove PHPUnit functions polyfill (#1395) Update branch names for GHA workflows (#1390) PHPLIB-1419 Encode Agg builder objects in Collection methods (#1383) ...
* v1.x: (101 commits) PHPLIB-1541: Include specs repository as a submodule (#1429) PHPLIB-1548 Inherit `typeMap` option in `Collection::listSearchIndexes()` (#1482) Fix array shape for `Collection::listSearchIndex($options)` (#1480) PHPLIB-1545: Deprecate CreateCollection flags option and related constants (#1477) Fix junit logging (#1475) Deprecate typeMap on operations without meaningful result (#1473) PHPLIB-1369 Upgrade to PHPUnit 10 (#1412) Higher phpunit version required (#1463) Fix deprecations in tests (#1458) Deprecate functionality to be removed (#1441) Expect BulkWriteException (#1455) Merge v1.20 into v1.x (#1447) PHPLIB-1525 Removes dependency to Symfony PHPUnit bridge (#1413) Change deprecated assertObjectHasAttribute to assertObjectHasProperty (#1432) Performance: Keep collections and indexes between GridFS tests (#1421) Add final annotations to non-internal Operation classes (#1410) Fix types accepted by $round (#1401) Replace arrayHasKey with assertArrayHasKey in tests (#1403) PHPLIB-1514 Make data providers static (#1404) PHPLIB-1515 Replace assertObjectHasAttribute with assertObjectHasProperty (#1405) ...
Fix PHPLIB-1514
In order to upgrade to PHPUnit 10+, we need to make all data provider static.