PHP Classes
elePHPant
Icontem

File: tests/InsertReturnIdTest.php

Recommend this page to a friend!
  Classes of Scott Arciszewski  >  EasyDB  >  tests/InsertReturnIdTest.php  >  Download  
File: tests/InsertReturnIdTest.php
Role: Class source
Content type: text/plain
Description: Class source
Class: EasyDB
Simple Database Abstraction Layer around PDO
Author: By
Last change:
Date: 1 year ago
Size: 2,231 bytes
 

Contents

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

namespace
ParagonIE\EasyDB\Tests;

use
InvalidArgumentException;

class
InsertReturnIdTest extends InsertTest
{

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

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

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

   
/**
     * @dataProvider goodFactoryCreateArgument2EasyDBProvider
     * @param callable $cb
     */
   
public function testInsertReturnId(callable $cb)
    {
       
$db = $this->easyDBExpectedFromCallable($cb);
       
$this->assertEquals(
           
$db->insertReturnId('irrelevant_but_valid_tablename', ['foo' => 'bar']),
           
'1'
       
);
       
$this->assertEquals(
           
$db->insertReturnId('irrelevant_but_valid_tablename', ['foo' => 'bar2']),
           
'2'
       
);
    }
   
/**
     * @dataProvider goodFactoryCreateArgument2EasyDBProvider
     * @param callable $cb
     */
   
public function testInsertReturnIdException(callable $cb)
    {
       
$db = $this->easyDBExpectedFromCallable($cb);
       
$this->expectException(\Exception::class);
       
$this->assertEquals(
           
$db->insertReturnId('irrelevant_but_valid_tablename', [], 'bar'),
           
'bar'
       
);
    }
}