Added wtable in other file
This commit is contained in:
parent
e0b8e8e8e3
commit
731bdfcf82
3 changed files with 65 additions and 37 deletions
|
|
@ -1,6 +1,7 @@
|
|||
<?php
|
||||
|
||||
use PhangoApp\WPDO;
|
||||
use PhangoApp\WPDO\WPDO;
|
||||
use PhangoApp\WPDO\WTable;
|
||||
use PhangoApp\PhaUtils\Utils;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
|
|
@ -9,26 +10,50 @@ include("libraries/Utils.php");
|
|||
|
||||
Utils::load_config('config_test', 'settings');
|
||||
|
||||
$sql_table="CREATE TABLE table_test (
|
||||
`name` VARCHAR(255) NOT NULL default '',
|
||||
`last_name` VARCHAR(255) NOT NULL default '',
|
||||
`type` INT NOT NULL
|
||||
);";
|
||||
|
||||
$pdo=new WPDO('table_test', ['name', 'last_name', 'type']);
|
||||
|
||||
$pdo->connect();
|
||||
|
||||
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));
|
||||
$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
|
||||
*/
|
||||
|
|
@ -37,7 +62,7 @@ final class WPDOTest extends TestCase {
|
|||
{
|
||||
global $pdo;
|
||||
|
||||
$this->assertTrue($pdo->query('drop table table_test'));
|
||||
$this->assertTrue($pdo->query('drop table table_test', []));
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue