Download the PHP package magical-yuri/magical-girl without Composer
On this page you can find all versions of the php package magical-yuri/magical-girl. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package magical-girl
What is MagicalGirl?
This is a library that insert test-data to your database.
MagicalGirl generate the random value for test-data that suitable for your table in database, and insert the test-data.
Environment
- PHP 5.6
- MySQL 5.6
How to Install
You need Composer to install MagicalGirl.
1. Install Composer
2. Prepare 'composer.json'
3. Install MagicalGirl
Prepare to Use
1. Initialize
Please execute the following command.
2. Database Connection Setting
Please implement the method to get DB-host, DB-user-name and DB-password in 'lib/DB/DBConnections.php'
The following is an example, that database-name is 'example'.
3. Generate the Importer class for your Table
Execute the following command, and two files will be generated.
lib/DB/TableImporter/[shemaName]/[databaseName][tableName]Importer.php
lib/DB/TableImporter/[shemaName]/base/Base[schemaName][tableName]Importer.php
Do not modify the file that named 'Base...php'.
Every time you execute magicalgen command, it re-generate the file 'Base...php' from table structure of run time.
When you need to customize the Importer, please modify only the file '[databaseName][tableName]Importer.php'
4. Prepare Master-data
When you always need to import the same data, for example, master-data, you prepare the master-data formed tsv file.
Please prepare tsv file in following directory structure.
This tsv file does not include the header.
You can get this tsv file by executing the following command.
How to Use
For example, you can use MagicalGirl by creating the following file.
API
TableImporter class
__construct($option = null)
Create a TableImporter object.
MagicalGirl expect you to specify following values for $option.
Default option is OPTION_WITH_TRUNCATE.
- TableImporter::OPTION_WITHOUT_TRUNCATE
- MagicalGirl will truncate table before insert the test-data.
- TableImporter::OPTION_WITH_TRUNCATE
- MagicalGirl will not truncate table before insert the test-data.
addRow(array $values = array(), array $ngValues = array())
Insert test-data to your table.
@param array $values array(fieldName => value, ...) MagicalGirl will insert these values in these columns.
@param array $ngValues array(fieldName => array(value, value, ...)) MagicalGirl will never insert these values in these columns.
@access public
@return array $row array(fieldName => value, ...) actually inserted values
MasterDBImporter class
import($tsvDirPath = null)
Import the master-data from tsv files.
Default value of $tsvDirPath is masterData, generated by magicalinit command.
@param string $tsvDirPath directory path that has tsv files
@access public
@return void
How to Test the TableImporter class
I will explain how to test The TableImporter class that is auto-generated from magicalgen command or is customized by you.
You need 'phpunit'.
For example, you can test the TableImporter class by creating the following file.
Testing by executing the following command.
License
MIT
Copyright
MagicalGirl is Copyright 2014 by MagicalYuri.