Skip to content

Commit

Permalink
Revert "fix(test): adjust to account for detaching entities"
Browse files Browse the repository at this point in the history
This reverts commit c0c9de4.
  • Loading branch information
kbond committed Jan 16, 2023
1 parent 2fab778 commit 6452962
Showing 1 changed file with 13 additions and 21 deletions.
34 changes: 13 additions & 21 deletions tests/Doctrine/ORM/RepositoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,13 +202,12 @@ public function filter_with_inner_join(): void

$this->assertCount(5, $this->repo());

$results = $this->repo()->filter(Join::inner('relation'));
$results = \iterator_to_array($this->repo()->filter(Join::inner('relation')));

$this->assertCount(3, $results);
$this->assertQueryCount(4, function() use ($results) {
foreach ($results as $i => $result) {
$this->assertSame($i + 1, $result->relation->value);
}
$this->assertQueryCount(2, function() use ($results) {
$this->assertSame(2, $results[1]->relation->value);
$this->assertSame(3, $results[2]->relation->value);
});
}

Expand Down Expand Up @@ -239,19 +238,14 @@ public function filter_with_left_join(): void

$this->assertCount(5, $this->repo());

$results = $this->repo()->filter(Join::left('relation'));
$results = \iterator_to_array($this->repo()->filter(Join::left('relation')));

$relationValues = [];
$this->assertCount(5, $results);
$this->assertQueryCount(4, function() use ($results, &$relationValues) {
foreach ($results as $result) {
if ($result->relation) {
$relationValues[] = $result->relation->value;
}
}
$this->assertQueryCount(2, function() use ($results) {
$this->assertSame(1, $results[1]->relation->value);
$this->assertSame(2, $results[2]->relation->value);
$this->assertNull($results[3]->relation);
});

$this->assertSame([1, 2, 3], $relationValues);
}

/**
Expand Down Expand Up @@ -282,15 +276,13 @@ public function filter_with_join_and_scoped_select(): void

$this->assertCount(5, $this->repo());

$results = $this->repo()->filter(Join::inner('relation')->scope(
$results = \iterator_to_array($this->repo()->filter(Join::inner('relation')->scope(
Spec::andX(Spec::gt('value', 1), Spec::lt('value', 3))
));
)));

$this->assertCount(1, $results);
$this->assertQueryCount(2, function() use ($results) {
foreach ($results as $result) {
$this->assertSame(2, $result->relation->value);
}
$this->assertQueryCount(1, function() use ($results) {
$this->assertSame(2, $results[0]->relation->value);
});
}

Expand Down

0 comments on commit 6452962

Please sign in to comment.