. */ namespace Tests\Api\Models\RuleGroup; use Faker\Factory; use Laravel\Passport\Passport; use Log; use Tests\TestCase; use Tests\Traits\CollectsValues; use Tests\Traits\TestHelpers; /** * Class StoreControllerTest */ class StoreControllerTest extends TestCase { use TestHelpers, CollectsValues; /** * @return array */ public function emptyDataProvider(): array { return [[[]]]; } /** * */ public function setUp(): void { parent::setUp(); Passport::actingAs($this->user()); Log::info(sprintf('Now in %s.', get_class($this))); } /** * @return array */ public function storeDataProvider(): array { $minimalSets = $this->minimalSets(); $optionalSets = $this->optionalSets(); $regenConfig = [ 'title' => function () { $faker = Factory::create(); return $faker->uuid; }, ]; return $this->genericDataProvider($minimalSets, $optionalSets, $regenConfig); } /** * @return array */ private function minimalSets(): array { $faker = Factory::create(); return [ 'default_group' => [ 'parameters' => [], 'fields' => [ 'title' => $faker->uuid, ], ], ]; } /** * @return \array[][] */ private function optionalSets(): array { $faker = Factory::create(); return [ 'description' => [ 'fields' => [ 'description' => $faker->uuid, ], ], 'order' => [ 'fields' => [ 'order' => $faker->numberBetween(1, 5), ], ], 'active' => [ 'fields' => [ 'active' => $faker->boolean, ], ], ]; } /** * @param array $submission * * emptyDataProvider / storeDataProvider * * @dataProvider storeDataProvider */ public function testStore(array $submission): void { if ([] === $submission) { $this->markTestSkipped('Empty data provider'); } $route = 'api.v1.rule_groups.store'; $this->storeAndCompare($route, $submission); } }