PHP Classes
elePHPant
Icontem

File: tests/InsertManyTest.php

Recommend this page to a friend!
  Classes of Scott Arciszewski  >  EasyDB  >  tests/InsertManyTest.php  >  Download  
File: tests/InsertManyTest.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: 1 year ago
Size: 2,523 bytes
 

 

Contents

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

namespace
ParagonIE\EasyDB\Tests;

use
InvalidArgumentException;
use
PDOException;

class
InsertManyTest extends EasyDBWriteTest
{

   
/**
     * @dataProvider goodFactoryCreateArgument2EasyDBProvider
     * @param callable $cb
     */
   
public function testInsertManyNoFieldsThrowsException(callable $cb)
    {
       
$db = $this->easyDBExpectedFromCallable($cb);
       
$this->expectException(InvalidArgumentException::class);
       
$this->assertFalse($db->insertMany('irrelevant_but_valid_tablename', []));
    }

   
/**
     * @dataProvider goodFactoryCreateArgument2EasyDBProvider
     * @param callable $cb
     */
   
public function testInsertManyNoFieldsThrowsPdoException(callable $cb)
    {
       
$db = $this->easyDBExpectedFromCallable($cb);
       
$this->expectException(PDOException::class);
       
$db->insertMany('irrelevant_but_valid_tablename', [[], [1]]);
    }

   
/**
     * @dataProvider goodFactoryCreateArgument2EasyDBProvider
     * @param callable $cb
     */
   
public function testInsertManyArgTableThrowsException(callable $cb)
    {
       
$db = $this->easyDBExpectedFromCallable($cb);
       
$this->expectException(InvalidArgumentException::class);
       
$db->insertMany('', [['foo' => 1], ['foo' => 2]]);
    }

   
/**
     * @dataProvider goodFactoryCreateArgument2EasyDBProvider
     * @param callable $cb
     */
   
public function testInsertManyArgMapKeysThrowsException(callable $cb)
    {
       
$db = $this->easyDBExpectedFromCallable($cb);
       
$this->expectException(InvalidArgumentException::class);
       
$db->insertMany('irrelevant_but_valid_tablename', [['1foo' => 1]]);
    }

   
/**
     * @dataProvider goodFactoryCreateArgument2EasyDBProvider
     * @param callable $cb
     */
   
public function testInsertManyArgMapIs1DArrayThrowsException(callable $cb)
    {
       
$db = $this->easyDBExpectedFromCallable($cb);
       
$this->expectException(InvalidArgumentException::class);
       
$db->insertMany('irrelevant_but_valid_tablename', [['foo' => [1]]]);
    }

   
/**
     * @dataProvider goodFactoryCreateArgument2EasyDBProvider
     * @param callable $cb
     */
   
public function testInsertMany(callable $cb)
    {
       
$db = $this->easyDBExpectedFromCallable($cb);
       
$db->insertMany('irrelevant_but_valid_tablename', [['foo' => '1'], ['foo' => '2']]);
       
$this->assertEquals(
           
$db->single('SELECT COUNT(*) FROM irrelevant_but_valid_tablename'),
           
2
       
);
    }
}