add: more tests
This commit is contained in:
parent
ce7f620984
commit
fcd76cf130
11 changed files with 232 additions and 15 deletions
|
@ -2,14 +2,45 @@
|
|||
|
||||
namespace Tests\Http\Controllers\CsvController\CsvCostCalc;
|
||||
|
||||
use App\Http\Controllers\CsvController\CsvCostCalc\CsvMinuteCostCalc;
|
||||
use App\Http\Controllers\CsvController\CsvCostCalc\CsvTotalCostCalc;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class CsvTotalCostCalcTest extends TestCase
|
||||
{
|
||||
|
||||
public function testTotal_time_cost()
|
||||
{
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->CsvTotalCostCalc = new CsvTotalCostCalc();
|
||||
$this->mockCsvMinuteCostCalc = $this->createMock(CsvMinuteCostCalc::class);
|
||||
$this->CsvTotalCostCalc->CsvMinuteCostCalc = $this->mockCsvMinuteCostCalc;
|
||||
}
|
||||
public function testSum_costs()
|
||||
{
|
||||
$array = [
|
||||
'Request By'=>'RequestBy/Client',
|
||||
'Priority'=>'Priority/High',
|
||||
];
|
||||
|
||||
$total_time = 3600;
|
||||
|
||||
//Valori presi dalla classe di test di CsvMinuteCostCalcTest
|
||||
$this->mockCsvMinuteCostCalc
|
||||
->expects($this->once())
|
||||
->method('select_correct_cost')
|
||||
->with('RequestBy/Client', 'Priority/High')
|
||||
->willReturn(1.26); // Mocked return value
|
||||
|
||||
$expected = [
|
||||
'Request By'=>'RequestBy/Client',
|
||||
'Priority'=>'Priority/High',
|
||||
'Tempo totale'=>'01:00:00',
|
||||
'Costo totale'=>75.61,
|
||||
];
|
||||
|
||||
$result = $this->CsvTotalCostCalc->total_time_cost($array, $total_time);
|
||||
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue