Skip to content
This repository was archived by the owner on Feb 24, 2026. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@
},
"require": {
"php": "^5.6 || ^7.0",
"fzaninotto/faker": "^1.8",
"nelmio/alice": "^2.2",
"wp-cli/wp-cli": "^2.0"
"wp-cli/wp-cli": "^2.0",
"fakerphp/faker": "^1.13",
"nelmio/alice": "^3.8",
"theofidry/alice-data-fixtures": "^1.4"
},
"require-dev": {
"behat/behat": "^2.5",
"squizlabs/php_codesniffer": "^2.9"
"behat/behat": "^3.8",
"squizlabs/php_codesniffer": "^3.5"
}
}
1 change: 0 additions & 1 deletion src/Command.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php

namespace Trendwerk\Faker;

use WP_CLI;
Expand Down
19 changes: 15 additions & 4 deletions src/Entity/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@

class User extends Entity
{
public $acf;
public $user_pass;
public $user_login;
public $user_nicename;
public $user_url;
public $user_email;
public $user_login;
public $user_nicename;
public $user_url;
public $user_email;
public $display_name;
public $nickname;
public $first_name;
Expand All @@ -33,6 +34,13 @@ public function persist()

update_user_meta($this->id, '_fake', true);

if (class_exists('acf') && $this->acf) {
foreach ($this->acf as $name => $value) {
$field = acf_get_field($name);
update_field($field['key'], $value, $this->id);
}
}

if ($this->meta) {
foreach ($this->meta as $key => $value) {
update_user_meta($this->id, $key, $value);
Expand Down Expand Up @@ -68,6 +76,9 @@ protected function getUserData()
{
$data = get_object_vars($this);

unset($data['acf']);
unset($data['meta']);

return array_filter($data);
}
}
10 changes: 5 additions & 5 deletions src/Faker.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
namespace Trendwerk\Faker;

use Nelmio\Alice\Fixtures\Loader;
use Nelmio\Alice\Loader\NativeLoader;

final class Faker
{
Expand All @@ -11,15 +11,15 @@ final class Faker
public function __construct($files)
{
$this->files = $files;
$this->loader = new Loader(get_locale(), [new Provider\Term]);
$this->loader = new NativeLoader();
}

public function persist(ProgressBar $progressBar)
{
$persister = new Persister($progressBar);

foreach ($this->files as $file) {
$objects = $this->loader->load($file);
$objects = $this->loader->loadFile($file);
$persister->persist($objects);
}
}
Expand All @@ -29,8 +29,8 @@ public function getObjectCount()
$objects = [];

foreach ($this->files as $file) {
$set = $this->loader->load($file);
$objects = array_merge($objects, $set);
$set = $this->loader->loadFile($file);
$objects = array_merge($objects, $set->getObjects());
}

return count($objects);
Expand Down
8 changes: 4 additions & 4 deletions src/Persister.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
namespace Trendwerk\Faker;

use Nelmio\Alice\PersisterInterface;
use Fidry\AliceDataFixtures\Persistence\PersisterInterface;

final class Persister implements PersisterInterface
{
Expand All @@ -12,15 +12,15 @@ public function __construct(ProgressBar $progressBar)
$this->progressBar = $progressBar;
}

public function persist(array $objects)
public function persist($objects)
{
foreach ($objects as $object) {
foreach ($objects->getObjects() as $object) {
$object->persist();
$this->progressBar->tick();
}
}

public function find($class, $id)
public function flush()
{
}
}