PHP Classes

File: tests/QuoteTest.php

Recommend this page to a friend!
  Packages of Scott Arciszewski   EasyDB   tests/QuoteTest.php   Download  
File: tests/QuoteTest.php
Role: Class source
Content type: text/plain
Description: Class source
Class: EasyDB
Simple Database Abstraction Layer around PDO
Author: By
Last change: Test Improvements + Mutation Testing (#168)

* Update testing frameworks
* Add infection for mutation tests
* Modernize PHPUnit usage
Date: 3 months ago
Size: 1,360 bytes
 

Contents

Class file image Download
<?php
declare(strict_types=1);

namespace
ParagonIE\EasyDB\Tests;

use
ParagonIE\EasyDB\EasyDB;
use
ParagonIE\EasyDB\Factory;
use
PHPUnit\Framework\Attributes\CoversClass;
use
PHPUnit\Framework\Attributes\DataProvider;

/**
 * Class ExecTest
 * @package ParagonIE\EasyDB\Tests
 */
#[CoversClass(EasyDB::class)]
#[CoversClass(Factory::class)]
class QuoteTest extends EasyDBTestCase
{

   
/**
     * @dataProvider goodFactoryCreateArgument2EasyDBQuoteProvider
     * @param callable $cb
     * @param $quoteThis
     * @param array $expectOneOfThese
     */
    #[DataProvider("goodFactoryCreateArgument2EasyDBQuoteProvider")]
   
public function testQuote(callable $cb, $quoteThis, array $expectOneOfThese): void
   
{
       
$db = $this->easyDBExpectedFromCallable($cb);

       
$this->assertTrue(count($expectOneOfThese) > 0);

       
$matchedOneOfThose = false;
       
$quoted = $db->quote((string)$quoteThis);

        foreach (
$expectOneOfThese as $expectThis) {
            if (
$quoted === $expectThis) {
               
$this->assertSame($quoted, $expectThis);
               
$matchedOneOfThose = true;
            }
        }
        if (!
$matchedOneOfThose) {
           
$this->assertTrue(
               
false,
               
'Did not match ' . $quoted . ' against any of ' . implode('; ', $expectOneOfThese)
            );
        }
    }
}