2024-07-22 14:17:00 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Tests\Http\Controllers\CsvController\CsvCostCalc;
|
|
|
|
|
2024-08-14 12:46:25 +02:00
|
|
|
use App\Http\Controllers\CsvController\CsvCostCalc\CsvMinuteCostCalc;
|
|
|
|
use App\Http\Controllers\CsvController\CsvCostCalc\CsvTotalCostCalc;
|
2024-08-17 18:06:06 +02:00
|
|
|
use Tests\TestCase;
|
2024-07-22 14:17:00 +02:00
|
|
|
|
|
|
|
class CsvSumTotalsCalcTest extends TestCase
|
|
|
|
{
|
|
|
|
|
2024-08-17 18:06:06 +02:00
|
|
|
protected function setUp(): void
|
|
|
|
{parent::setUp();
|
|
|
|
|
2024-08-14 12:46:25 +02:00
|
|
|
$this->CsvTotalCostCalc = new CsvTotalCostCalc();
|
|
|
|
$this->mockCsvMinuteCostCalc = $this->createMock(CsvMinuteCostCalc::class);
|
|
|
|
$this->CsvTotalCostCalc->CsvMinuteCostCalc = $this->mockCsvMinuteCostCalc;
|
|
|
|
}
|
2024-07-22 14:17:00 +02:00
|
|
|
public function testSum_costs()
|
|
|
|
{
|
2024-08-14 12:46:25 +02:00
|
|
|
$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);
|
2024-07-22 14:17:00 +02:00
|
|
|
|
2024-08-14 12:46:25 +02:00
|
|
|
$this->assertEquals($expected, $result);
|
2024-07-22 14:17:00 +02:00
|
|
|
}
|
|
|
|
}
|