mirror of
https://github.com/dg/dibi.git
synced 2025-08-29 16:59:49 +02:00
added .travis.yml & other files
This commit is contained in:
42
tests/dibi/DibiFluent.cloning.phpt
Normal file
42
tests/dibi/DibiFluent.cloning.phpt
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Test: Cloning of DibiFluent
|
||||
*
|
||||
* @author David Grudl
|
||||
*/
|
||||
|
||||
|
||||
|
||||
require __DIR__ . '/bootstrap.php';
|
||||
|
||||
|
||||
dibi::connect($config['sqlite3']);
|
||||
|
||||
|
||||
$fluent = new DibiFluent(dibi::getConnection());
|
||||
$fluent->select('*')->from('table')->where('x=1');
|
||||
$dolly = clone $fluent;
|
||||
$dolly->where('y=1');
|
||||
$dolly->clause('FOO');
|
||||
|
||||
Assert::same( 'SELECT * FROM [table] WHERE x=1', (string) $fluent );
|
||||
Assert::same( 'SELECT * FROM [table] WHERE x=1 AND y=1 FOO', (string) $dolly );
|
||||
|
||||
|
||||
|
||||
$fluent = dibi::select('id')->from('table')->where('id = %i',1);
|
||||
$dolly = clone $fluent;
|
||||
$dolly->where('cd = %i',5);
|
||||
|
||||
Assert::same( 'SELECT [id] FROM [table] WHERE id = 1', (string) $fluent );
|
||||
Assert::same( 'SELECT [id] FROM [table] WHERE id = 1 AND cd = 5', (string) $dolly );
|
||||
|
||||
|
||||
|
||||
$fluent = dibi::select("*")->from("table");
|
||||
$dolly = clone $fluent;
|
||||
$dolly->removeClause("select")->select("count(*)");
|
||||
|
||||
Assert::same( 'SELECT * FROM [table]', (string) $fluent );
|
||||
Assert::same( 'SELECT count(*) FROM [table]', (string) $dolly );
|
14
tests/dibi/bootstrap.php
Normal file
14
tests/dibi/bootstrap.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Test initialization and helpers.
|
||||
*
|
||||
* @author David Grudl
|
||||
*/
|
||||
|
||||
require __DIR__ . '/../../vendor/nette/tester/Tester/bootstrap.php';
|
||||
require __DIR__ . '/../../dibi/dibi.php';
|
||||
$config = require __DIR__ . '/config.php';
|
||||
|
||||
date_default_timezone_set('Europe/Prague');
|
||||
class_alias('Tester\Assert', 'Assert');
|
77
tests/dibi/config.php
Normal file
77
tests/dibi/config.php
Normal file
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
|
||||
return array(
|
||||
'mysql' => array(
|
||||
'driver' => 'mysql',
|
||||
'host' => 'localhost',
|
||||
'username' => 'root',
|
||||
'password' => 'xxx',
|
||||
'charset' => 'utf8',
|
||||
),
|
||||
|
||||
'mysqli' => array(
|
||||
'driver' => 'mysqli',
|
||||
'host' => 'localhost',
|
||||
'username' => 'dibi',
|
||||
'password' => 'dibi',
|
||||
'charset' => 'utf8',
|
||||
),
|
||||
|
||||
'sqlite' => array(
|
||||
'driver' => 'sqlite',
|
||||
'database' => dirname(__FILE__) . '/data/sample.sdb',
|
||||
),
|
||||
|
||||
'sqlite3' => array(
|
||||
'driver' => 'sqlite3',
|
||||
'database' => dirname(__FILE__) . '/data/sample.sdb3',
|
||||
),
|
||||
|
||||
'odbc' => array(
|
||||
'driver' => 'odbc',
|
||||
'username' => 'dibi',
|
||||
'password' => 'dibi',
|
||||
'dsn' => 'Driver={Microsoft Access Driver (*.mdb)};Dbq=' . dirname(__FILE__) . '/data/sample.mdb',
|
||||
),
|
||||
|
||||
'postgresql' => array(
|
||||
'driver' => 'postgre',
|
||||
'host' => 'localhost',
|
||||
'port' => '5432',
|
||||
'username' => 'dibi',
|
||||
'password' => 'dibi',
|
||||
'persistent' => '1',
|
||||
),
|
||||
|
||||
'sqlite-pdo' => array(
|
||||
'driver' => 'pdo',
|
||||
'dsn' => 'sqlite2::' . dirname(__FILE__) . '/data/sample.sdb',
|
||||
),
|
||||
|
||||
'mysql-pdo' => array(
|
||||
'driver' => 'pdo',
|
||||
'dsn' => 'mysql:host=localhost',
|
||||
'username' => 'dibi',
|
||||
'password' => 'dibi',
|
||||
),
|
||||
|
||||
'mssql' => array(
|
||||
'driver' => 'mssql',
|
||||
'host' => 'localhost',
|
||||
'username' => 'dibi',
|
||||
'password' => 'dibi',
|
||||
),
|
||||
|
||||
'mssql2005' => array(
|
||||
'driver' => 'mssql2005',
|
||||
'host' => '(local)',
|
||||
'username' => 'dibi',
|
||||
'password' => 'dibi',
|
||||
),
|
||||
|
||||
'oracle' => array(
|
||||
'driver' => 'oracle',
|
||||
'username' => 'dibi',
|
||||
'password' => 'dibi',
|
||||
),
|
||||
);
|
BIN
tests/dibi/data/sample.mdb
Normal file
BIN
tests/dibi/data/sample.mdb
Normal file
Binary file not shown.
149
tests/dibi/data/sample.mysql.sql
Normal file
149
tests/dibi/data/sample.mysql.sql
Normal file
@@ -0,0 +1,149 @@
|
||||
-- phpMyAdmin SQL Dump
|
||||
-- version 2.11.1.2
|
||||
-- http://www.phpmyadmin.net
|
||||
--
|
||||
-- Po<50><6F>ta<74>: localhost
|
||||
-- Vygenerov<6F>no: Ned<65>le 02. prosince 2007, 19:49
|
||||
-- Verze MySQL: 5.0.45
|
||||
-- Verze PHP: 5.2.1
|
||||
|
||||
SET FOREIGN_KEY_CHECKS=0;
|
||||
|
||||
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
|
||||
|
||||
--
|
||||
-- Datab<61>ze: `dibi`
|
||||
--
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Struktura tabulky `customers`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `customers`;
|
||||
CREATE TABLE IF NOT EXISTS `customers` (
|
||||
`customer_id` int(11) NOT NULL auto_increment,
|
||||
`name` varchar(100) default NULL,
|
||||
PRIMARY KEY (`customer_id`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=7 ;
|
||||
|
||||
--
|
||||
-- Vypisuji data pro tabulku `customers`
|
||||
--
|
||||
|
||||
INSERT INTO `customers` (`customer_id`, `name`) VALUES
|
||||
(1, 'Dave Lister'),
|
||||
(2, 'Arnold Rimmer'),
|
||||
(3, 'The Cat'),
|
||||
(4, 'Holly'),
|
||||
(5, 'Kryten'),
|
||||
(6, 'Kristine Kochanski');
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Struktura tabulky `enumtest`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `enumtest`;
|
||||
CREATE TABLE IF NOT EXISTS `enumtest` (
|
||||
`id` int(11) NOT NULL auto_increment,
|
||||
`test` enum('a','b','c') NOT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
|
||||
|
||||
--
|
||||
-- Vypisuji data pro tabulku `enumtest`
|
||||
--
|
||||
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Struktura tabulky `orders`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `orders`;
|
||||
CREATE TABLE IF NOT EXISTS `orders` (
|
||||
`order_id` int(11) NOT NULL,
|
||||
`customer_id` int(11) NOT NULL,
|
||||
`product_id` int(11) NOT NULL,
|
||||
`amount` float NOT NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
||||
|
||||
--
|
||||
-- Vypisuji data pro tabulku `orders`
|
||||
--
|
||||
|
||||
INSERT INTO `orders` (`order_id`, `customer_id`, `product_id`, `amount`) VALUES
|
||||
(1, 2, 1, 7),
|
||||
(2, 2, 3, 2),
|
||||
(3, 1, 2, 3),
|
||||
(4, 6, 3, 5);
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Struktura tabulky `products`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `products`;
|
||||
CREATE TABLE IF NOT EXISTS `products` (
|
||||
`product_id` int(11) NOT NULL auto_increment,
|
||||
`title` varchar(100) default NULL,
|
||||
PRIMARY KEY (`product_id`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
|
||||
|
||||
--
|
||||
-- Vypisuji data pro tabulku `products`
|
||||
--
|
||||
|
||||
INSERT INTO `products` (`product_id`, `title`) VALUES
|
||||
(1, 'Chair'),
|
||||
(2, 'Table'),
|
||||
(3, 'Computer');
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Struktura tabulky `settest`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `settest`;
|
||||
CREATE TABLE IF NOT EXISTS `settest` (
|
||||
`id` int(11) NOT NULL auto_increment,
|
||||
`test` set('a','b','c') NOT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
|
||||
|
||||
--
|
||||
-- Vypisuji data pro tabulku `settest`
|
||||
--
|
||||
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Struktura tabulky `where`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `where`;
|
||||
CREATE TABLE IF NOT EXISTS `where` (
|
||||
`select` int(11) NOT NULL,
|
||||
`dot.dot` int(11) NOT NULL,
|
||||
`is` int(11) NOT NULL,
|
||||
`quot'n' space` int(11) NOT NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
||||
|
||||
--
|
||||
-- Vypisuji data pro tabulku `where`
|
||||
--
|
||||
|
||||
INSERT INTO `where` (`select`, `dot.dot`, `is`, `quot'n' space`) VALUES
|
||||
(1, 2, 3, 4);
|
||||
|
||||
SET FOREIGN_KEY_CHECKS=1;
|
||||
|
||||
SET SQL_MODE="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION";
|
||||
|
BIN
tests/dibi/data/sample.sdb
Normal file
BIN
tests/dibi/data/sample.sdb
Normal file
Binary file not shown.
BIN
tests/dibi/data/sample.sdb3
Normal file
BIN
tests/dibi/data/sample.sdb3
Normal file
Binary file not shown.
Reference in New Issue
Block a user