wpdo/tests/WPDOTest.php

69 lines
1.4 KiB
PHP

<?php
use PhangoApp\WPDO\WPDO;
use PhangoApp\WPDO\WTable;
use PhangoApp\PhaUtils\Utils;
use PHPUnit\Framework\TestCase;
include("vendor/autoload.php");
include("libraries/Utils.php");
Utils::load_config('config_test', 'settings');
final class WPDOTest extends TestCase {
public function testConnect()
{
global $pdo;
$table=new WTable('table_test', ['name', 'last_name', 'type']);
$pdo=new WPDO($table);
$this->assertTrue($pdo->connect());
}
public function testCreateTable()
{
global $pdo;
$sql_table="DROP TABLE IF EXISTS table_test;
CREATE TABLE table_test (
`name` VARCHAR(255) NOT NULL default '',
`last_name` VARCHAR(255) NOT NULL default '',
`type` INT NOT NULL
);";
$this->assertTrue($pdo->query($sql_table, []));
}
/**
* @depends testCreateTable
*/
public function testInsert() {
global $pdo;
$this->assertEquals('table_test', $pdo->table->name);
$this->assertTrue($pdo->insert(['name', 'last_name', 'type'], ['first', 'last', '1']));
}
/**
* @depends testCreateTable
*/
public function testDropTable()
{
global $pdo;
$this->assertTrue($pdo->query('drop table table_test', []));
}
}