Skip to content

Commit

Permalink
add a test for updates without where conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
tflori committed Nov 5, 2023
1 parent 0d6c6d3 commit f57b1f4
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions tests/Dbal/Other/UpdateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Mockery as m;
use ORM\Dbal\Other;
use ORM\QueryBuilder\QueryBuilder;
use ORM\Test\TestCase;

class UpdateTest extends TestCase
Expand Down Expand Up @@ -35,4 +36,14 @@ public function updatesEscapedValues()

$this->dbal->update('examples', ['id' => 42], ['col1' => 'hempel\'s sofa', 'col2' => 23]);
}

/** @test */
public function doesNotNeedWhereConditions()
{
$this->pdo->shouldReceive('query')->with('UPDATE "questions" SET "answer" = 42')
->once()->andReturn($statement = m::mock(\PDOStatement::class));
$statement->shouldReceive('rowCount')->andReturn(1);

$this->dbal->update('questions', [], ['answer' => 42]);
}
}

0 comments on commit f57b1f4

Please sign in to comment.