Faker

Faker is a tool to generate fake data.

https://github.com/FakerPHP/Faker support was added to Tiki18 as one of the Packages, allowing to generate fake tracker items to facilitate testing tracker or Search and List from Unified Index performance, for instance.

How to use it

You can use it through the Console command line script.

Syntax

Copy to clipboard
php console.php faker:tracker [-f|--field [FIELD]] [-i|--items [ITEMS]] [-r|--random-status] [--reuse-files [REUSE-FILES]] [--] <tracker>

Added comments for Tiki 20:

Copy to clipboard
php console.php faker:comments <object> [<type>] -i, --items[=ITEMS] Number of comments (items) to generate [default: 100] -r, --replies[=REPLIES] Percentage of comments as replies [default: 40] -a, --anonymous[=ANONYMOUS] Percentage of anonymous posts if permitted [default: 20] -s, --minstart[=MINSTART] Earliest start date for first comment [default: "-1 year"] -e, --maxstart[=MAXSTART] Latest start date for first comment [default: "-11 months"] --mingap[=MINGAP] Shortest gap between comments [default: "10 minutes"] -g, --maxgap[=MAXGAP] Longest gap between comments [default: "5 days"]

Example

Command to create 5 new items, with random tracker item status (open, pending or closed), on tracker 1:

Copy to clipboard
php console.php faker:tracker -i 5 -r -- 1


Command to create 200 new comments on tracker item 42 starting from about 2 months ago with a maximum gap of 2 hours between each:

Copy to clipboard
php console.php faker:comments -i200 -s'-2 months' -e'-6 weeks' -g'2 hours' 42 trackeritem

Define Formatters in Tracker Fields

New in Tiki 22 and introduced in 07d46e8a

You can now add defined fakers for each field, so you can instruct it to use names, dates, number ranges and so on as described here.

Examples

First name
~tc~faker:firstName~/tc~
Last name
~tc~faker:lastName~/tc~~
Number from 1 to 100
~tc~faker: numberBetween,1,100~/tc~~/np~
Date in the last 6 months
~tc~faker:dateTimeBetween,-6 months~/tc~~/np~

Note, the faker formatter goes in a Tiki Comment in the field description so if you enable the wiki parsing it won't show to users.