Skip to content

PHPLIB-682: Add test for Database::dropCollection() #847

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

Merged
merged 3 commits into from
Jul 27, 2021

Conversation

tanlisu
Copy link
Contributor

@tanlisu tanlisu commented Jul 26, 2021

@tanlisu tanlisu requested a review from jmikola July 26, 2021 18:12

$commandResult = $this->database->dropCollection($this->getCollectionName());
$this->assertCommandSucceeded($commandResult);
$this->assertCollectionCount($this->getNamespace(), 0);
Copy link
Member

Choose a reason for hiding this comment

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

Once #840 is merged, please change this use the assertCollectionDoesNotExist() method that was moved to the base class. Asserting that no collections exist in the namespace is not reliable. This is why DropCollectionFunctionalTest originally had its own assertCollectionDoesNotExist method.

I assume you might have copied this from testDrop. That case is different as we're dropping the entire database and should expect no collections to exist within it after the fact.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah my bad, I will fix that again

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I noticed that assertCollectionCount() is still being used in the testDrop() of CollectionFunctionalTest.php. Should I create a new ticket to fix that?

$this->assertCollectionCount($this->getNamespace(), 0);

Copy link
Member

@jmikola jmikola Jul 26, 2021

Choose a reason for hiding this comment

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

Ah, I didn't realize it was also being used there (dates back to c520df8#diff-1ab446f85499e8289fa4a8373d33f1aaadc5ffc63f5561dd6335342ef000b4d2R19). I originally assumed this was lifted from DatabaseFunctionalTest::testDrop.

Please do change CollectionFunctionalTest::testDrop to use assertCollectionCount.

@tanlisu tanlisu merged commit 95d84fb into mongodb:master Jul 27, 2021
@tanlisu tanlisu deleted the phplib-682 branch July 27, 2021 17:49
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