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
|
class CompanyValidationByNameTest extends TestCase
|
||||||
{
|
{
|
||||||
public function testCompanyWithEmptyName(): void
|
public function dataProvider() {
|
||||||
{
|
return [
|
||||||
$name = '';
|
'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,
|
||||||
|
]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dataProvider dataProvider
|
||||||
|
*/
|
||||||
|
public function testCompanyValidationWithName(string $name, string $key, string $message, bool $isValid): void
|
||||||
|
{
|
||||||
$validator = new CompanyValidationByName($name);
|
$validator = new CompanyValidationByName($name);
|
||||||
$json = $validator->getMessageMap();
|
$json = $validator->getMessageMap();
|
||||||
$isValid = $validator->isValid();
|
|
||||||
|
|
||||||
$this->assertEquals($json['error'], 'The company name is empty, please, write the name!!!');
|
$this->assertEquals($json[$key], $message);
|
||||||
$this->assertFalse($isValid);
|
$this->assertEquals($validator->isValid(), $isValid);
|
||||||
}
|
|
||||||
|
|
||||||
public function testNotExistingCompanyWithName(): 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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user