jebw / factory_lib Goto Github PK
View Code? Open in Web Editor NEWData Factory library for PHP - good for unit tests
Data Factory library for PHP - good for unit tests
FactoryLib ========== This is a simple data factory class - for generating rows in a database or associative arrays of data, normally used in testing. To use it include factory_lib.php and then define your tables. The database connection is the basic mysql_* functions. include dirname(__FILE__) . "/factory_lib.php" ; Factory::$factory_data['my_table_name'] = array('forename' => 'Jeremy', 'surname' => Wilkins, 'age' => 32) ; This will define the default data - you can create a row in the database with this data by doing Factory::create('my_table_name') ; and just get an array of data using Factory::hash('my_table_name') ; Either of these take a second parameter of overriding data, and fields not set will use the defaults, eg Factory::create('my_table_name', array('age' => 21)) ; You can also include the magic value {{counter}} in strings for creating multiple rows, each with unique data - eg. Factory::$factory_data['testing'] => array('name' => 'Test User {{counter}}') for($i = 0; $i < 5; $i++) Factory::create('testing') ; Will create 5 rows, with names Test User 1 to Test User 5. You can also use UNIX_TIMESTAMP() and NOW() as magic string values - these will get passed through to mysql automatically rather than being escaped and inserted as text. Factory::truncate('my_table_name') will trunctate the named table (good for the setUp() function in unit tests).
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.