PHP Classes

File: tests/SingleTestIs1DArrayThenDeleteReadOnlyTestThenDeleteWriteTest.php

Recommend this page to a friend!
  Classes of Scott Arciszewski   EasyDB   tests/SingleTestIs1DArrayThenDeleteReadOnlyTestThenDeleteWriteTest.php   Download  
File: tests/SingleTestIs1DArrayThenDeleteReadOnlyTestThenDeleteWriteTest.php
Role: Class source
Content type: text/plain
Description: Class source
Class: EasyDB
Simple Database Abstraction Layer around PDO
Author: By
Last change: manually changing to squish "method name is not in camel caps format" style error
single-lining test classes after composer run fix-style
running composer run fix-style
Date: 6 years ago
Size: 1,914 bytes
 

Contents

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

namespace
ParagonIE\EasyDB\Tests;

class
SingleTestIs1DArrayThenDeleteReadOnlyTestThenDeleteWriteTest extends EasyDBWriteTest
{

   
/**
     * @dataProvider goodFactoryCreateArgument2EasyDBInsertManyProvider
     * @depends ParagonIE\EasyDB\Tests\Is1DArrayThenDeleteReadOnlyTest::testDeleteThrowsException
     * @depends ParagonIE\EasyDB\Tests\Is1DArrayThenDeleteReadOnlyTest::testDeleteTableNameEmptyThrowsException
     * @depends ParagonIE\EasyDB\Tests\Is1DArrayThenDeleteReadOnlyTest::testDeleteTableNameInvalidThrowsException
     * @depends ParagonIE\EasyDB\Tests\Is1DArrayThenDeleteReadOnlyTest::testDeleteConditionsReturnsNull
     * @depends ParagonIE\EasyDB\Tests\InsertManyTest::testInsertMany
     * @depends ParagonIE\EasyDB\Tests\SingleTest::testMethod
     * @param callable $cb
     * @param array $insertMany
     */
   
public function testDelete(callable $cb, array $insertMany)
    {
       
$db = $this->easyDBExpectedFromCallable($cb);
       
$db->insertMany('irrelevant_but_valid_tablename', $insertMany);
       
$insertManyTotal = count($insertMany);
       
$this->assertEquals(
           
$db->single('SELECT COUNT(*) FROM irrelevant_but_valid_tablename'),
           
$insertManyTotal
       
);
        foreach (
$insertMany as $insertVal) {
           
$this->assertEquals(
               
$db->single(
                   
'SELECT COUNT(*) FROM irrelevant_but_valid_tablename WHERE foo = ?',
                   
array_values($insertVal)
                ),
               
1
           
);
        }
        for (
$i=0; $i<$insertManyTotal; ++$i) {
           
$db->delete('irrelevant_but_valid_tablename', $insertMany[$i]);
           
$this->assertEquals(
               
$db->single('SELECT COUNT(*) FROM irrelevant_but_valid_tablename'),
                (
$insertManyTotal - ($i + 1))
            );
        }
    }
}