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

PHPLIB-1514 Make data providers static #1404

Merged
merged 5 commits into from
Sep 16, 2024
Merged

Conversation

GromNaN
Copy link
Member

@GromNaN GromNaN commented Sep 13, 2024

Fix PHPLIB-1514

In order to upgrade to PHPUnit 10+, we need to make all data provider static.

@GromNaN GromNaN requested a review from a team as a code owner September 13, 2024 19:21
{
return [123, 3.14, 'foo', true, [], new stdClass(), $this->createMock(Codec::class)];
return [123, 3.14, 'foo', true, [], new stdClass(), self::createStub(Codec::class)];
Copy link
Member Author

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.

Copy link
Member Author

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.

@jmikola
Copy link
Member

jmikola commented Sep 13, 2024

Do you want to address the six errors in this CI build first?

Copy link
Member

@jmikola jmikola left a 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 = '')
Copy link
Member

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 👍

Copy link
Member Author

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()
Copy link
Member

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);
Copy link
Member

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?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@GromNaN GromNaN merged commit 3724afc into mongodb:v1.x Sep 16, 2024
31 checks passed
@GromNaN GromNaN deleted the PHPLIB-1514 branch September 16, 2024 07:00
This was referenced Sep 16, 2024
alcaeus added a commit that referenced this pull request Sep 19, 2024
* 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
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants