Skip to content

Commit

Permalink
Merge pull request #16649 from cakephp/datbase-query-tests
Browse files Browse the repository at this point in the history
Don't use the ORM for Database/Query tests.
  • Loading branch information
ADmad committed Jul 27, 2022
2 parents 35b1b52 + d0fa103 commit da7c5ed
Show file tree
Hide file tree
Showing 4 changed files with 328 additions and 217 deletions.
26 changes: 12 additions & 14 deletions tests/TestCase/Database/QueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3572,10 +3572,9 @@ public function testTupleComparisonValuesAreBeingBoundCorrectly(): void
'This test fails sporadically in SQLServer'
);

$profiles = $this->getTableLocator()->get('Profiles');

$query = $profiles
->find()
$query = (new Query($this->connection))
->select('*')
->from('profiles')
->where(
new TupleComparison(
['id', 'user_id'],
Expand All @@ -3585,7 +3584,7 @@ public function testTupleComparisonValuesAreBeingBoundCorrectly(): void
)
);

$result = $query->firstOrFail();
$result = $query->execute()->fetch(StatementInterface::FETCH_TYPE_ASSOC);

$bindings = array_values($query->getValueBinder()->bindings());
$this->assertCount(2, $bindings);
Expand All @@ -3594,8 +3593,8 @@ public function testTupleComparisonValuesAreBeingBoundCorrectly(): void
$this->assertSame(1, $bindings[1]['value']);
$this->assertSame('integer', $bindings[1]['type']);

$this->assertSame(1, $result['id']);
$this->assertSame(1, $result['user_id']);
$this->assertSame(1, (int)$result['id']);
$this->assertSame(1, (int)$result['user_id']);
}

/**
Expand All @@ -3613,10 +3612,9 @@ public function testTupleComparisonTypesCanBeOmitted(): void
'This test fails sporadically in SQLServer'
);

$profiles = $this->getTableLocator()->get('Profiles');

$query = $profiles
->find()
$query = (new Query($this->connection))
->select('*')
->from('profiles')
->where(
new TupleComparison(
['id', 'user_id'],
Expand All @@ -3625,7 +3623,7 @@ public function testTupleComparisonTypesCanBeOmitted(): void
'IN'
)
);
$result = $query->firstOrFail();
$result = $query->execute()->fetch(StatementInterface::FETCH_TYPE_ASSOC);

$bindings = array_values($query->getValueBinder()->bindings());
$this->assertCount(2, $bindings);
Expand All @@ -3634,8 +3632,8 @@ public function testTupleComparisonTypesCanBeOmitted(): void
$this->assertSame(1, $bindings[1]['value']);
$this->assertNull($bindings[1]['type']);

$this->assertSame(1, $result['id']);
$this->assertSame(1, $result['user_id']);
$this->assertSame(1, (int)$result['id']);
$this->assertSame(1, (int)$result['user_id']);
}

/**
Expand Down

0 comments on commit da7c5ed

Please sign in to comment.