Skip to content

Commit

Permalink
[5.2] Test for #13242 (#13751)
Browse files Browse the repository at this point in the history
* Using mockery for consistency

* Add a test for removed bindings as per #13242
  • Loading branch information
sebwas authored and taylorotwell committed May 29, 2016
1 parent 35a5d64 commit dbfd364
Showing 1 changed file with 23 additions and 6 deletions.
29 changes: 23 additions & 6 deletions tests/Database/DatabaseQueryBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1267,20 +1267,37 @@ public function testMySqlUpdateWrappingJson()
$grammar = new Illuminate\Database\Query\Grammars\MySqlGrammar;
$processor = m::mock('Illuminate\Database\Query\Processors\Processor');

// Couldn't get mockery to work
$connection = $this->getMock('Illuminate\Database\ConnectionInterface');
$connection->expects($this->once())
->method('update')
$connection = m::mock('Illuminate\Database\ConnectionInterface');
$connection->shouldReceive('update')
->once()
->with(
$this->equalTo('update `users` set `name` = json_set(`name`, "$.first_name", ?), `name` = json_set(`name`, "$.last_name", ?) where `active` = ?'),
$this->equalTo(['John', 'Doe', 1])
'update `users` set `name` = json_set(`name`, "$.first_name", ?), `name` = json_set(`name`, "$.last_name", ?) where `active` = ?',
['John', 'Doe', 1]
);

$builder = new Builder($connection, $grammar, $processor);

$result = $builder->from('users')->where('active', '=', 1)->update(['name->first_name' => 'John', 'name->last_name' => 'Doe']);
}

public function testMySqlUpdateWithJsonRemovesBindingsCorrectly()
{
$grammar = new Illuminate\Database\Query\Grammars\MySqlGrammar;
$processor = m::mock('Illuminate\Database\Query\Processors\Processor');

$connection = m::mock('Illuminate\Database\ConnectionInterface');
$connection->shouldReceive('update')
->once()
->with(
'update `users` set `options` = json_set(`options`, "$.enable", false), `updated_at` = ? where `id` = ?',
['2015-05-26 22:02:06', 0]
);

$builder = new Builder($connection, $grammar, $processor);

$result = $builder->from('users')->where('id', '=', 0)->update(['options->enable' => false, 'updated_at' => '2015-05-26 22:02:06']);
}

public function testMySqlWrappingJsonWithString()
{
$builder = $this->getMySqlBuilder();
Expand Down

0 comments on commit dbfd364

Please sign in to comment.