TagDAOTest.php 989 B

123456789101112131415161718192021222324252627282930
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * Tests for the database-specific `INSERT ... ON DUPLICATE` variants used when tagging entries.
  5. */
  6. final class TagDAOTest extends \PHPUnit\Framework\TestCase {
  7. private const SQL = 'INSERT INTO `_entrytag`(id_tag, id_entry) VALUES(:id_tag, :id_entry)';
  8. public function test_sqlIgnoreConflict_forMySQL(): void {
  9. self::assertSame(
  10. 'INSERT IGNORE INTO `_entrytag`(id_tag, id_entry) VALUES(:id_tag, :id_entry)',
  11. FreshRSS_TagDAO::sqlIgnoreConflict(self::SQL),
  12. );
  13. }
  14. public function test_sqlIgnoreConflict_forSQLite(): void {
  15. self::assertSame(
  16. 'INSERT OR IGNORE INTO `_entrytag`(id_tag, id_entry) VALUES(:id_tag, :id_entry)',
  17. FreshRSS_TagDAOSQLite::sqlIgnoreConflict(self::SQL),
  18. );
  19. }
  20. public function test_sqlIgnoreConflict_forPostgreSQL(): void {
  21. self::assertSame(
  22. 'INSERT INTO `_entrytag`(id_tag, id_entry) VALUES(:id_tag, :id_entry) ON CONFLICT DO NOTHING',
  23. FreshRSS_TagDAOPGSQL::sqlIgnoreConflict(self::SQL),
  24. );
  25. }
  26. }