DeleteTest.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. namespace Medoo\Tests;
  3. use Medoo\Medoo;
  4. /**
  5. * @coversDefaultClass \Medoo\Medoo
  6. */
  7. class DeleteTest extends MedooTestCase
  8. {
  9. /**
  10. * @covers ::delete()
  11. * @dataProvider typesProvider
  12. */
  13. public function testDelete($type)
  14. {
  15. $this->setType($type);
  16. $this->database->delete("account", [
  17. "AND" => [
  18. "type" => "business",
  19. "age[<]" => 18
  20. ]
  21. ]);
  22. $this->assertQuery(
  23. <<<EOD
  24. DELETE FROM "account"
  25. WHERE ("type" = 'business' AND "age" < 18)
  26. EOD,
  27. $this->database->queryString
  28. );
  29. }
  30. /**
  31. * @covers ::delete()
  32. * @dataProvider typesProvider
  33. */
  34. public function testDeleteRaw($type)
  35. {
  36. $this->setType($type);
  37. $whereClause = Medoo::raw("WHERE (<type> = :type AND <age> < :age)", [
  38. ':type' => 'business',
  39. ':age' => 18,
  40. ]);
  41. $this->database->delete("account", $whereClause);
  42. $this->assertQuery(
  43. <<<EOD
  44. DELETE FROM "account"
  45. WHERE ("type" = 'business' AND "age" < 18)
  46. EOD,
  47. $this->database->queryString
  48. );
  49. }
  50. }