Refactor the validation tests and remove example test.
continuous-integration/drone/push Build is failing
continuous-integration/drone/push Build is failing
This commit is contained in:
@@ -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
|
||||
{
|
||||
public function testCompanyWithEmptyName(): void
|
||||
{
|
||||
$name = '';
|
||||
|
||||
$validator = new CompanyValidationByName($name);
|
||||
$json = $validator->getMessageMap();
|
||||
$isValid = $validator->isValid();
|
||||
|
||||
$this->assertEquals($json['error'], 'The company name is empty, please, write the name!!!');
|
||||
$this->assertFalse($isValid);
|
||||
public function dataProvider() {
|
||||
return [
|
||||
'Invalid Case' => [
|
||||
'name' => '',
|
||||
'key' => 'error',
|
||||
'message' => 'The company name is empty, please, write the name!!!',
|
||||
'isValid' => false,
|
||||
],
|
||||
'Not Found Case' => [
|
||||
'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);
|
||||
$json = $validator->getMessageMap();
|
||||
$isValid = $validator->isValid();
|
||||
|
||||
$this->assertEquals($json['ok'], 'A company with the name is valid.');
|
||||
$this->assertTrue($isValid);
|
||||
$this->assertEquals($json[$key], $message);
|
||||
$this->assertEquals($validator->isValid(), $isValid);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ class ItemValidationByNameTest extends TestCase
|
||||
/**
|
||||
* @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);
|
||||
$json = $validator->getMessageMap();
|
||||
|
||||
@@ -34,7 +34,7 @@ class UserValidationTest extends TestCase
|
||||
/**
|
||||
* @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);
|
||||
$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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user