| 1 |
<?php |
| 2 |
|
| 3 |
namespace Give\TestData\Framework\Provider; |
| 4 |
|
| 5 |
/** |
| 6 |
* Returns a random Author ID from the users table. |
| 7 |
*/ |
| 8 |
class RandomAuthor extends RandomProvider |
| 9 |
{ |
| 10 |
|
| 11 |
public function __invoke() |
| 12 |
{ |
| 13 |
$authorIDs = get_users( |
| 14 |
[ |
| 15 |
'fields' => 'ID', |
| 16 |
'role__in' => ['administrator', 'editor', 'author'], |
| 17 |
] |
| 18 |
); |
| 19 |
|
| 20 |
return $this->faker->randomElement($authorIDs); |
| 21 |
} |
| 22 |
} |
| 23 |
|