Refactor the validation tests and remove example test.
continuous-integration/drone/push Build is failing Details

main
KKlochko 2 years ago
parent 8c62393d3f
commit 8fda7eae83

@ -1,19 +0,0 @@
<?php
namespace Tests\Feature;
// use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class ExampleTest extends TestCase
{
/**
* A basic test example.
*/
public function test_the_application_returns_a_successful_response(): void
{
$response = $this->get('/');
$response->assertStatus(200);
}
}

@ -8,39 +8,38 @@ use App\Models\Validation\CompanyValidationByName;
class CompanyValidationByNameTest extends TestCase class CompanyValidationByNameTest extends TestCase
{ {
public function testCompanyWithEmptyName(): void public function dataProvider() {
{ return [
$name = ''; 'Invalid Case' => [
'name' => '',
$validator = new CompanyValidationByName($name); 'key' => 'error',
$json = $validator->getMessageMap(); 'message' => 'The company name is empty, please, write the name!!!',
$isValid = $validator->isValid(); 'isValid' => false,
],
$this->assertEquals($json['error'], 'The company name is empty, please, write the name!!!'); 'Not Found Case' => [
$this->assertFalse($isValid); 'name' => '404 Company',
'key' => 'error',
'message' => 'A company with the name does not exist!!!',
'isValid' => false,
],
'Found Case' => [
'name' => 'testCompany',
'key' => 'ok',
'message' => 'A company with the name is valid.',
'isValid' => true,
]
];
} }
public function testNotExistingCompanyWithName(): void /**
* @dataProvider dataProvider
*/
public function testCompanyValidationWithName(string $name, string $key, string $message, bool $isValid): void
{ {
$name = '404 Company';
$validator = new CompanyValidationByName($name);
$json = $validator->getMessageMap();
$isValid = $validator->isValid();
$this->assertEquals($json['error'], 'A company with the name does not exist!!!');
$this->assertFalse($isValid);
}
public function testValidCompanyWithName(): void
{
$name = 'testCompany';
$validator = new CompanyValidationByName($name); $validator = new CompanyValidationByName($name);
$json = $validator->getMessageMap(); $json = $validator->getMessageMap();
$isValid = $validator->isValid();
$this->assertEquals($json['ok'], 'A company with the name is valid.'); $this->assertEquals($json[$key], $message);
$this->assertTrue($isValid); $this->assertEquals($validator->isValid(), $isValid);
} }
} }

@ -34,7 +34,7 @@ class ItemValidationByNameTest extends TestCase
/** /**
* @dataProvider dataProvider * @dataProvider dataProvider
*/ */
public function testCityValidationWithName(string $name, string $key, string $message, bool $isValid): void public function testItemValidationWithName(string $name, string $key, string $message, bool $isValid): void
{ {
$validator = new ItemValidationByName($name); $validator = new ItemValidationByName($name);
$json = $validator->getMessageMap(); $json = $validator->getMessageMap();

@ -34,7 +34,7 @@ class UserValidationTest extends TestCase
/** /**
* @dataProvider dataProvider * @dataProvider dataProvider
*/ */
public function testCityValidationWithName(string $name, string $key, string $message, bool $isValid): void public function testUserValidationWithName(string $name, string $key, string $message, bool $isValid): void
{ {
$validator = new UserValidationByMatrixUsername($name); $validator = new UserValidationByMatrixUsername($name);
$json = $validator->getMessageMap(); $json = $validator->getMessageMap();

@ -1,16 +0,0 @@
<?php
namespace Tests\Unit;
use PHPUnit\Framework\TestCase;
class ExampleTest extends TestCase
{
/**
* A basic test example.
*/
public function test_that_true_is_true(): void
{
$this->assertTrue(true);
}
}
Loading…
Cancel
Save