Loading...
 
Skip to main content

History: Faker

Source of version: 17 (current)

Copy to clipboard
            {syntax type="markdown"  editor="wysiwyg"} # {{page}}

Faker is a tool to generate fake data.

https://github.com/FakerPHP/Faker support was [http://sourceforge.net/p/tikiwiki/code/63674|added] to ((Tiki18)) as one of the ((Packages)), allowing to generate fake tracker items to facilitate testing ((Trackers|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

{CODE(colors="shell" ln="1")}
php console.php faker:tracker [-f|<strike>field [FIELD]] [-i|</strike>items [ITEMS]] [-r|<strike>random-status] [</strike>reuse-files [REUSE-FILES]] [--] <tracker>
{CODE} 
Added comments for Tiki 20: 
{CODE(colors="shell" ln="1")}
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"]
{CODE}

### Example

Command to create 5 new items, with random tracker item status (open, pending or closed), on tracker 1: 
{CODE(colors="shell")}
php console.php faker:tracker -i 5 -r -- 1
{CODE}

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: 
{CODE(colors="shell")}
php console.php faker:comments -i200 -s'-2 months' -e'-6 weeks' -g'2 hours' 42 trackeritem
{CODE}

## Define Formatters in Tracker Fields

*New in Tiki 22 and introduced in [https://gitlab.com/tikiwiki/tiki/-/commit/07d46e8a|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 [https://github.com/fzaninotto/Faker#formatters|here].

### Examples

First name
: \~t~np~c~/np~\~faker:firstName\~/tc\~

Last name
: \~t\~np©/np{HTML()}<span style="color:faker">lastName~/tc</span>{HTML}

Number from 1 to 100
: \~t\~np©/np{HTML()}<span style="color:faker"> numberBetween,1,100~/tc</span>{HTML}/np\~

Date in the last 6 months
: \~t\~np©/np{HTML()}<span style="color:faker">dateTimeBetween,-6 months~/tc</span>{HTML}/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.