Skip to content

Commit

Permalink
Added test for value object in conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzo committed Apr 3, 2016
1 parent f52cea8 commit 0b92431
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tests/TestCase/Database/ExpressionTypeCastingIntegrationTest.php
Expand Up @@ -48,6 +48,9 @@ public function toPHP($value, Driver $d)

public function toExpression($value)
{
if ($value instanceof UuidValue) {
$value = $value->value;
}
$substr = function ($start, $length = null) use ($value) {
return new FunctionExpression(
'SUBSTR',
Expand Down Expand Up @@ -139,6 +142,26 @@ public function testSelectWithConditions()
$this->assertEquals('4c2681c048298a29a7fb413140cf8569', $result[0]['id']);
}


/**
* Tests Select using value object in conditions
*
* @return void
*/
public function testSelectWithConditionsValueObject()
{
$this->_insert();
$result = $this->connection->newQuery()
->select('id')
->from('ordered_uuid_items')
->where(['id' => new UuidValue('48298a29-81c0-4c26-a7fb-413140cf8569')], ['id' => 'ordered_uuid'])
->execute()
->fetchAll('assoc');

$this->assertCount(1, $result);
$this->assertEquals('4c2681c048298a29a7fb413140cf8569', $result[0]['id']);
}

/**
* Tests using the expression type in with an IN condition
*
Expand Down

0 comments on commit 0b92431

Please sign in to comment.