Faker - generating test data for database > stdout.in Ievgen Kuzminov IT blog

Faker - generating test data for database

Feb 6, 2014, 9:27:23 AM

Faker is a library that provide a set of generators for data types like fake name, address, number, IP, email, lorem ipsum text etc. - all generic data that is needed to create semi-real database content. Usually it has variations for different popular languages. All data is human-readable and taken from library, a lot of different combinations creates semi-unique data set.

It is needed mostly on testing and demonstration stages. Nobody likes to see a list of users like "test1", "Johnny35" etc. with posts "Test1", "Another test 35".

Implementation

PHP usage example

$faker = Faker\Factory::create();

// generate data by accessing properties
echo $faker->name;
  // 'Lucy Cechtelar';
echo $faker->address;
  // "426 Jordy Lodge
  // Cartwrightshire, SC 88120-6700"
echo $faker->text;
  // Sint velit eveniet. Rerum atque repellat voluptatem quia rerum. Numquam excepturi
  // beatae sint laudantium consequatur. Magni occaecati itaque sint et sit tempore. Nesciunt ...
for ($i=0; $i < 5; $i++) {
  echo $faker->name, "\n";
}
  // Adaline Reichel
  // Dr. Santa Prosacco DVM
  // Noemy Vandervort V
  // Lexi O'Conner
  // Gracie Weber

NB! Yii2 Framework has a Faker fixtures extensions

Ievgen
Kuzminov "iJackUA"
Web Team Lead
at MobiDev (Kharkiv, Ukraine)
Code in Ruby and Elixir, but still love PHP. Explore ES6 and Vue.js. Explore databases, use Ubuntu and MacOS, think about IT people and management

Notes


Gor tool for capturing and replaying live HTTP traffic into a test environment in order to continuously test your system with real data. It can be used to increase confidence in code deployments, configuration changes and infrastructure changes.



Gush - a parallel workflow runner using only Redis as its message broker and Sidekiq for workers.



iFrame Resize automatic resizing of the height and width of both same and cross domain iFrames to fit their contained content.



pgBackRest aims to be a simple, reliable backup and restore system that can seamlessly scale up to the largest databases and workloads.