Skip to content

Commit

Permalink
Merge pull request #2177 from alcaeus/fix-flaky-test
Browse files Browse the repository at this point in the history
Use majority write concern to fix flaky test
  • Loading branch information
malarzm authored Apr 22, 2020
2 parents 1c6fade + 7a5eedb commit d91c17b
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public function setUp()
$user = new User();
$user->addGroup(new Group('Test'));
$this->dm->persist($user);
$this->dm->flush();
$this->dm->flush(null, ['w' => 'majority']);
$this->dm->clear();
}

Expand All @@ -31,6 +31,7 @@ public function testHintIsNotSetByDefault()
$this->assertArrayNotHasKey(Query::HINT_READ_PREFERENCE_TAGS, $cursor->getHints());

$user = $cursor->getSingleResult();
$this->assertInstanceOf(User::class, $user);

$this->assertInstanceOf('Doctrine\ODM\MongoDB\PersistentCollection', $user->getGroups());
$this->assertArrayNotHasKey(Query::HINT_READ_PREFERENCE, $user->getGroups()->getHints());
Expand All @@ -53,6 +54,7 @@ public function testHintIsSetOnQuery($readPreference, array $tags = null)
$this->assertReadPreferenceTagsHint($tags, $cursor->getHints());

$user = $cursor->getSingleResult();
$this->assertInstanceOf(User::class, $user);

$this->assertInstanceOf('Doctrine\ODM\MongoDB\PersistentCollection', $user->getGroups());
$this->assertReadPreferenceHint($readPreference, $user->getGroups()->getHints());
Expand All @@ -79,6 +81,7 @@ public function testHintIsSetOnCursor($readPreference, array $tags = null)
$this->assertReadPreferenceTagsHint($tags, $cursor->getHints());

$user = $cursor->getSingleResult();
$this->assertInstanceOf(User::class, $user);

$this->assertInstanceOf('Doctrine\ODM\MongoDB\PersistentCollection', $user->getGroups());
$this->assertReadPreferenceHint($readPreference, $user->getGroups()->getHints());
Expand All @@ -100,8 +103,9 @@ public function testHintIsSetOnPersistentCollection($readPreference, array $tags
$this->assertArrayNotHasKey(Query::HINT_READ_PREFERENCE_TAGS, $cursor->getHints());

$user = $cursor->getSingleResult();
$groups = $user->getGroups();
$this->assertInstanceOf(User::class, $user);

$groups = $user->getGroups();
$this->assertInstanceOf('Doctrine\ODM\MongoDB\PersistentCollection', $groups);

$groups->setHints(array(
Expand Down

0 comments on commit d91c17b

Please sign in to comment.