Skip to content

Latest commit

 

History

History
142 lines (113 loc) · 5.04 KB

coverage.md

File metadata and controls

142 lines (113 loc) · 5.04 KB

Test cases coverage of all library functions

How to use

First of all you need to create the test database

DROP DATABASE IF EXISTS `testdb`;
CREATE DATABASE IF NOT EXISTS `testdb`;
USE `testdb`;

CREATE TABLE `test_query` (
  `id` int NOT NULL,
  `key` varchar(25) NOT NULL,
  `value` varchar(50) NOT NULL
);

CREATE TABLE `test_table` (
  `id` int NOT NULL,
  `name` varchar(25) NOT NULL COMMENT 'It contains the name',
  `date` date NOT NULL,
  `value` varchar(15) NOT NULL
);

INSERT INTO `test_table` (`id`, `name`, `date`, `value`) VALUES (1, 'John', '2022-01-01', 'Red');
INSERT INTO `test_table` (`id`, `name`, `date`, `value`) VALUES (2, 'John2', '2022-06-01', 'Yellow');

ALTER TABLE `test_query`
  ADD PRIMARY KEY (`id`);

ALTER TABLE `test_table`
  ADD PRIMARY KEY (`id`);

ALTER TABLE `test_query`
  MODIFY `id` int NOT NULL AUTO_INCREMENT;

ALTER TABLE `test_table`
  MODIFY `id` int NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;

OR, just type

mysql -uroot -p < tests/db.sql

after this, you can use PHPUnit

user@pc:/var/www/html/ultimatemysql$ composer install
user@pc:/var/www/html/ultimatemysql$ ./vendor/bin/phpunit --testdox tests

Groups of functions

Actual coverage: 65/65 100%

MYSQL

  • MySQL __construct ([boolean $connect = true], [string $database = ""], [string $server = ""], [string $username = ""], [string $password = ""], [string $charset = ""])
  • void __destruct ()
  • object Returns Close ()
  • boolean IsConnected ()
  • boolean Open ([string $database = ""], [string $server = ""], [string $username = ""], [string $password = ""], [string $charset = ""], [boolean $pcon = false])
  • boolean Release ()

BUILD

  • string BuildSQLDelete (string $tableName, array $whereArray)
  • string BuildSQLInsert (string $tableName, array $valuesArray)
  • string BuildSQLSelect (string $tableName, [array $whereArray = null], [array/string $columns = null], [array/string $sortColumns = null], [boolean $sortAscending = true], [integer/string $limit = null])
  • string BuildSQLUpdate (string $tableName, array $valuesArray, [array $whereArray = null])
  • string BuildSQLWhereClause (array $whereArray)

COLUMNS

  • array GetColumnComments (string $table)
  • integer GetColumnCount ([string $table = ""])
  • string GetColumnDataType (string $column, [string $table = ""])
  • integer GetColumnID (string $column, [string $table = ""])
  • integer GetColumnLength (string $column, [string $table = ""])
  • integer GetColumnName (string $columnID, [string $table = ""])
  • array GetColumnNames ([string $table = ""])
  • array GetTables ()

EXPORT

  • string GetHTML ([boolean $showCount = true], [string $styleTable = null], [string $styleHeader = null], [string $styleData = null])
  • string GetJSON ()
  • boolean GetXML ()

TIMER

  • Float TimerDuration ([integer $decimals = 4])
  • void TimerStart ()
  • void TimerStop ()
  • object PHP QueryTimed (string $sql)

QUERY

  • object PHP Query (string $sql)
  • array QueryArray (string $sql, [integer $resultType = MYSQL_BOTH])
  • object PHP QuerySingleRow (string $sql)
  • array QuerySingleRowArray (string $sql, [integer $resultType = MYSQL_BOTH])
  • mixed QuerySingleValue (string $sql)
  • boolean AutoInsertUpdate (string $tableName, array $valuesArray, array $whereArray)
  • integer InsertRow (string $tableName, array $valuesArray)
  • boolean UpdateRows (string $tableName, array $valuesArray, [array $whereArray = null])
  • boolean DeleteRows (string $tableName, [array $whereArray = null])
  • integer GetLastInsertID ()
  • string GetLastSQL ()
  • string HasRecords ([string $sql = ""])
  • object PHP Records ()
  • Records RecordsArray ([integer $resultType = MYSQL_BOTH])
  • object PHP Row ([integer $optional_row_number = null])
  • array RowArray ([integer $optional_row_number = null], [integer $resultType = MYSQL_BOTH])
  • integer RowCount ()
  • boolean TruncateTable (string $tableName)
  • boolean SelectDatabase (string $database, [string $charset = ""])
  • boolean SelectRows (string $tableName, [array $whereArray = null], [array/string $columns = null], [array/string $sortColumns = null], [boolean $sortAscending = true], [integer/string $limit = null])
  • boolean SelectTable (string $tableName)

VALUES

  • boolean GetBooleanValue (any $value)
  • boolean IsDate (date/string $value)
  • string SQLBooleanValue (any $value, any $trueValue, any $falseValue, [string $datatype = self::SQLVALUE_TEXT])
  • string SQLFix (string $value)
  • string SQLValue (any $value, [string $datatype = self::SQLVALUE_TEXT])

ERRORS

  • string Error ()
  • integer ErrorNumber ()

SEEK

  • boolean MoveFirst ()
  • boolean MoveLast ()
  • boolean BeginningOfSeek ()
  • boolean EndOfSeek ()
  • object Fetched Seek (integer $row_number)
  • integer SeekPosition ()

TRANSACTIONS

  • boolean TransactionBegin ()
  • boolean TransactionEnd ()
  • boolean TransactionRollback ()