Skip to content

Commit

Permalink
Fixing lastInserId() use
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzo committed Mar 19, 2016
1 parent 135aa72 commit fef4769
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions tests/TestCase/Database/QueryTest.php
Expand Up @@ -3604,16 +3604,18 @@ public function testSelectTypeConversion()
public function testSymetricJsonType()
{
$query = new Query($this->connection);
$id = $query
$insert = $query
->insert(['comment', 'article_id', 'user_id'], ['comment' => 'json'])
->into('comments')
->values([
'comment' => ['a' => 'b', 'c' => true],
'article_id' => 1,
'user_id' => 1
])
->execute()
->lastInsertId('id');
->execute();

$id = $insert->lastInsertId('comments', 'id');
$insert->closeCursor();

$query = new Query($this->connection);
$query
Expand All @@ -3622,8 +3624,10 @@ public function testSymetricJsonType()
->where(['id' => $id])
->selectTypeMap()->types(['comment' => 'json']);

$result = $query->execute()->fetchAll('assoc')[0]['comment'];
$this->assertSame(['a' => 'b', 'c' => true], $result);
$result = $query->execute();
$comment = $result->fetchAll('assoc')[0]['comment'];
$result->closeCursor();
$this->assertSame(['a' => 'b', 'c' => true], $comment);
}

/**
Expand Down

0 comments on commit fef4769

Please sign in to comment.