YAML/XML Dataset Generator from your current DB for PHPUnit DB Test
You need fixtures to execute DB related tests.
Sometimes FW might support you, but in other cases you have to create them manually.
DB_to_Fixtures generates YAML/XML Dataset for PHPUnit fixtures from your current database.
- YAML Dataset for PHPUnit DB test
- XML Dataset for PHPUnit DB test(not fully tested)
- PostgreSQL
- MySQL
- sqlite
- PHP 5.3 or higher
- PHPUnit 3.7 or higher with DBUnit and Symfony/YAML
- And one or more of DBMS below
- PostgreSQL 8.4 or higher
- MySQL 5.0 or higher
- SQLite 3.7 or higher
- Setup db.config.php suitable to your environment.
- Type the command line as below
$ php main.php --table=your_table_name
- Now you get "your_table_name.yml" under "outfiles" directory.
(You need an appropriate privilege, of course.) - Enjoy your DB test with PHPUnit by using the generated YML Dataset See http://www.phpunit.de/manual/3.7/en/database.html
You can see command line tips by typing
$ php main.php --help
-
Basic Test
$ phpunit ymlTest.php
$ phpunit UtilTest.php
$ phpunit sqliteTest.php
(with sqlite installed) -
Other DBs
If you are using MySQL/PostgreSQL, create database "test" first.
Modify test/resources/mysql.config.php(pgsql.config.php) depending on your environment.
$ phpunit mysqlTest.php
$ phpunit pgsqlTest.php
- untidy-hair
Feel free to report me anything! Forking the repository is welcome.
Copyright (c) 2012-2013 Yukio Mizuta
MIT License http://www.opensource.org/licenses/mit-license