word(); $sorts = collect()->pad(fake()->numberBetween(2, 9), $key); $attribute = fake()->word(); $validator = Validator::make( [$attribute => $sorts->join(',')], [$attribute => new DistinctIgnoringDirectionRule()] ); $this->assertFalse($validator->passes()); }); test('fails if duplicate sort different direction', function (): void { $key = fake()->word(); $sort = new Sort($key); $sorts = []; foreach (Direction::cases() as $direction) { $sorts[] = $sort->format($direction); } $attribute = fake()->word(); $validator = Validator::make( [$attribute => implode(',', $sorts)], [$attribute => new DistinctIgnoringDirectionRule()] ); $this->assertFalse($validator->passes()); }); test('passes if no duplicates', function (): void { $sorts = collect(fake()->words(fake()->randomDigitNotNull()))->unique(); $attribute = fake()->word(); $validator = Validator::make( [$attribute => $sorts->join(',')], [$attribute => new DistinctIgnoringDirectionRule()] ); $this->assertTrue($validator->passes()); });