123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- <?php
- namespace Tests\Feature\API;
- use App\Models\NamingRule;
- use Illuminate\Foundation\Testing\RefreshDatabase;
- use Illuminate\Foundation\Testing\WithFaker;
- use Tests\Feature\TestCase;
- class NamingRuleTest extends TestCase
- {
- public function test_create_naming_rule(): void
- {
- $form = NamingRule::factory()->make();
- $response = $this->post(route('naming-rule.store'), $form->toArray());
- $response->assertStatus(201);
- }
- public function test_naming_rule_list()
- {
- NamingRule::factory(30)->create();
- $response = $this->get(route('naming-rule.index'));
- $response->assertStatus(200)
- ->assertJsonStructure([
- 'data' => [
- '*' => [
- 'id',
- 'name',
- 'global',
- 'status',
- 'company'
- ]
- ]
- ]);
- }
- public function test_naming_rule_enabled()
- {
- NamingRule::factory(30)->create();
- $response = $this->get(route('naming-rule.enabled'));
- $response->assertStatus(200)
- ->assertJsonStructure([
- 'data' => [
- '*' => [
- 'id',
- 'name',
- ]
- ]
- ]);
- }
- public function test_naming_rule_show(): void
- {
- $namingRule = NamingRule::factory()->create();
- $response = $this->get(route('naming-rule.show', ['naming_rule' => $namingRule->id]));
- $response->assertStatus(200)
- ->assertJsonStructure([
- 'data' => [
- 'id',
- 'name',
- 'global',
- 'status',
- 'company'
- ]
- ]);
- }
- public function test_naming_rule_update(): void
- {
- $namingRule = NamingRule::factory()->create();
- $form = NamingRule::factory()->make();
- $response = $this->put(route('naming-rule.update', ['naming_rule' => $namingRule->id]), $form->toArray());
- $response->assertStatus(204);
- $newAsset = NamingRule::find($namingRule->id);
- $this->assertEquals($form->name, $newAsset->name);
- }
- private function test_naming_rule_delete(): void
- {
- $namingRule = NamingRule::factory()->create();
- $response = $this->delete(route('naming-rule.destroy', ['naming_rule' => $namingRule->id]));
- $response->assertStatus(204);
- $this->assertNull(NamingRule::find($namingRule->id));
- }
- }
|