Add ValidationByName and CompanyValidationByName.
continuous-integration/drone/push Build is passing
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use Tests\TestCase;
|
||||
|
||||
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 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);
|
||||
}
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use Tests\TestCase;
|
||||
|
||||
use App\Models\Company;
|
||||
|
||||
class CompanyValidationTest extends TestCase
|
||||
{
|
||||
public function testCompanyWithEmptyName(): void
|
||||
{
|
||||
$json = Company::validateWithName('');
|
||||
|
||||
$this->assertEquals($json['error'], 'The company name is empty, please, write the name!!!');
|
||||
}
|
||||
|
||||
public function testNotExistingCompanyWithName(): void
|
||||
{
|
||||
$name = '404 Company';
|
||||
|
||||
$json = Company::validateWithName($name);
|
||||
|
||||
$this->assertEquals($json['error'], 'A company with the name does not exist!!!');
|
||||
}
|
||||
|
||||
public function testValidCompanyWithName(): void
|
||||
{
|
||||
$name = 'testCompany';
|
||||
|
||||
$json = Company::validateWithName($name);
|
||||
|
||||
$this->assertEquals($json['ok'], 'A company with the name is valid.');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user