Skip to content

Commit

Permalink
refactor(test): Updating tests phpdoc to PHP Attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
gnovaro committed Sep 8, 2024
1 parent 76ed41a commit bcae008
Show file tree
Hide file tree
Showing 62 changed files with 143 additions and 93 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@
use App\Models\Lead;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\Mail;
use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase;

class ScheduleNotificationReminderTest extends TestCase
{
/** @test */
#[Test]
public function it_can_send_notifications(): void
{
Mail::fake();
Expand Down Expand Up @@ -41,7 +42,7 @@ public function it_can_send_notifications(): void
});
}

/** @test */
#[Test]
public function it_can_store_notifications(): void
{
$timezone = 'Europe/Madrid';
Expand Down
13 changes: 8 additions & 5 deletions tests/Feature/Controllers/Api/Auth/LoginControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@

namespace Tests\Feature\Controllers\Api\Auth;

use PHPUnit\Framework\Attributes\CoversMethod;
use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase;

class LoginControllerTest extends TestCase
{
/** @test */
#[Test]
//#[CoversMethod('App\Http\Controllers\Api\Auth\LoginController', 'login')]
public function it_can_login()
{
$credentials = ['email' => $this->user->email, 'password' => 'password'];
Expand All @@ -23,7 +26,7 @@ public function it_can_login()
$this->isAuthenticated('api');
}

/** @test */
#[Test]
public function it_can_not_login_with_wrong_credentials()
{
$credentials = ['email' => $this->user->email, 'password' => 'wrong_password'];
Expand All @@ -36,7 +39,7 @@ public function it_can_not_login_with_wrong_credentials()
$this->assertGuest('api');
}

/** @test */
#[Test]
public function it_can_get_credentials()
{
$this->actingAs($this->user, 'api');
Expand All @@ -48,7 +51,7 @@ public function it_can_get_credentials()
->assertExactJson($this->user->toArray());
}

/** @test */
#[Test]
public function it_can_logout()
{
$credentials = ['email' => $this->user->email, 'password' => 'password'];
Expand All @@ -64,7 +67,7 @@ public function it_can_logout()
$this->assertGuest('api');
}

/** @test */
#[Test]
public function it_can_refresh_token()
{
$credentials = ['email' => $this->user->email, 'password' => 'password'];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,16 @@

use App\Models\Industry;
use App\Models\Lead;
use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase;

class ContactCreateControllerTest extends TestCase
{
protected $jsonStructureContact = [
protected array $jsonStructureContact = [
'id',
];

/**
* @test
*/
#[Test]
public function can_create_contact(): void
{
$this->actingAs($this->user, 'api');
Expand Down Expand Up @@ -60,9 +59,7 @@ public function can_create_contact(): void
->assertSee($data['contact_phone']);
}

/**
* @test
*/
#[Test]
public function create_contact_have_missing_parameters(): void
{
$this->actingAs($this->user, 'api');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@

use App\Models\Customer;
use App\Models\User;
use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase;

class CustomerCreateControllerTest extends TestCase
{
/** @test */
#[Test]
public function it_can_save_customer(): void
{
$this->actingAs(User::factory()->create(), 'api');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@

use App\Models\Customer;
use App\Models\User;
use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase;

class CustomerListControllerTest extends TestCase
{
/** @test */
#[Test]
public function it_can_list_customer(): void
{
$this->actingAs(User::factory()->create(), 'api');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@

use App\Models\Customer;
use App\Models\User;
use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase;

class CustomerReadControllerTest extends TestCase
{
/** @test */
#[Test]
public function it_can_read_customer(): void
{
$this->actingAs(User::factory()->create(), 'api');
Expand All @@ -19,7 +20,7 @@ public function it_can_read_customer(): void
$this->assertEquals(array_except($response->json()['customer'], ['seller', 'industry', 'country']), $customer->toArray());
}

/** @test */
#[Test]
public function it_not_found_a_customer(): void
{
$this->actingAs(User::factory()->create(), 'api');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
<?php

declare(strict_types=1);

namespace Tests\Feature\Controllers\Api\Customer;

use App\Models\Customer;
use App\Models\User;
use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase;

class CustomerUpdateControllerTest extends TestCase
{
/** @test */
#[Test]
public function it_can_update_customer(): void
{
$this->actingAs(User::factory()->create(), 'api');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@

use App\Models\Lead;
use App\Models\User;
use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase;

class LeadCreateControllerTest extends TestCase
{
/** @test */
#[Test]
public function it_can_save_lead(): void
{
$this->actingAs(User::factory()->create(), 'api');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@

use App\Models\Lead;
use App\Models\User;
use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase;

class LeadListControllerTest extends TestCase
{
/** @test */
#[Test]
public function it_can_list_lead(): void
{
$this->actingAs(User::factory()->create(), 'api');
Expand Down
5 changes: 3 additions & 2 deletions tests/Feature/Controllers/Api/Lead/LeadReadControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@

use App\Models\Lead;
use App\Models\User;
use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase;

class LeadReadControllerTest extends TestCase
{
/** @test */
#[Test]
public function it_can_read_lead(): void
{
$this->actingAs(User::factory()->create(), 'api');
Expand All @@ -19,7 +20,7 @@ public function it_can_read_lead(): void
$this->assertEquals(array_except($response->json()['lead'], ['seller', 'industry', 'country', 'company']), $lead->toArray());
}

/** @test */
#[Test]
public function it_not_found_a_lead(): void
{
$this->actingAs(User::factory()->create(), 'api');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@

use App\Models\Lead;
use App\Models\User;
use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase;

class LeadUpdateControllerTest extends TestCase
{
/** @test */
#[Test]
public function it_can_update_lead(): void
{
$this->actingAs(User::factory()->create(), 'api');
Expand Down
3 changes: 2 additions & 1 deletion tests/Feature/Controllers/Bank/BankCreateControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

namespace Tests\Feature\Controllers\Bank;

use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase;

class BankCreateControllerTest extends TestCase
{
/** @test */
#[Test]
public function it_can_create_bank()
{
$response = $this->get('/bank/create');
Expand Down
3 changes: 2 additions & 1 deletion tests/Feature/Controllers/Bank/BankIndexControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
namespace Tests\Feature\Controllers\Bank;

use App\Models\Bank;
use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase;

class BankIndexControllerTest extends TestCase
{
/** @test */
#[Test]
public function it_can_index_bank()
{
$banks = Bank::factory()->count(2)->create();
Expand Down
5 changes: 3 additions & 2 deletions tests/Feature/Controllers/Bank/BankSaveControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
namespace Tests\Feature\Controllers\Bank;

use App\Models\Bank;
use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase;

class BankSaveControllerTest extends TestCase
{
/** @test */
#[Test]
public function it_can_save_bank(): void
{
$data = Bank::factory()->create()->toArray();
Expand All @@ -18,7 +19,7 @@ public function it_can_save_bank(): void
$this->equalTo(Bank::all()->last(), $data);
}

/** @test */
#[Test]
public function it_can_update_bank(): void
{
$data = Bank::factory()->create()->toArray();
Expand Down
3 changes: 2 additions & 1 deletion tests/Feature/Controllers/Bank/BankUpdateControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
namespace Tests\Feature\Controllers\Bank;

use App\Models\Bank;
use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase;

class BankUpdateControllerTest extends TestCase
{
/** @test */
#[Test]
public function it_can_update_bank(): void
{
$bank = Bank::factory()->create();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

namespace Tests\Feature\Controllers\Brand;

use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase;

class BrandCreateControllerTest extends TestCase
{
/** @test */
#[Test]
public function it_can_create_brand()
{
$response = $this->get('/brand/create');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
namespace Tests\Feature\Controllers\Brand;

use App\Models\Brand;
use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase;

class BrandDeleteControllerTest extends TestCase
{
/** @test */
#[Test]
public function it_can_delete_brand()
{
$brand = Brand::factory()->create();
Expand Down
3 changes: 2 additions & 1 deletion tests/Feature/Controllers/Brand/BrandIndexControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
namespace Tests\Feature\Controllers\Brand;

use App\Models\Brand;
use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase;

class BrandIndexControllerTest extends TestCase
{
/** @test */
#[Test]
public function it_can_index_brand()
{
$brands = Brand::factory()->count(2)->create(['company_id' => $this->user->company_id]);
Expand Down
5 changes: 3 additions & 2 deletions tests/Feature/Controllers/Brand/BrandSaveControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
namespace Tests\Feature\Controllers\Brand;

use App\Models\Brand;
use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase;

class BrandSaveControllerTest extends TestCase
{
/** @test */
#[Test]
public function it_can_save_brand(): void
{
$data = Brand::factory()->create(['company_id' => $this->user->company_id])->toArray();
Expand All @@ -18,7 +19,7 @@ public function it_can_save_brand(): void
$this->equalTo(Brand::all()->last(), $data);
}

/** @test */
#[Test]
public function it_can_update_brand(): void
{
$data = Brand::factory()->create(['company_id' => $this->user->company_id])->toArray();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
namespace Tests\Feature\Controllers\Brand;

use App\Models\Brand;
use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase;

class BrandUpdateControllerTest extends TestCase
{
/** @test */
#[Test]
public function it_can_update_brand(): void
{
$brand = Brand::factory()->create();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@

namespace Tests\Feature\Controllers\Company;

use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase;

class CompanyCreateControllerTest extends TestCase
{
/** @test */
#[Test]
public function it_can_create_company(): void
{
$response = $this->get('/company/create');
Expand Down
Loading

0 comments on commit bcae008

Please sign in to comment.