add: more tests
This commit is contained in:
parent
ce7f620984
commit
fcd76cf130
11 changed files with 232 additions and 15 deletions
|
@ -8,13 +8,80 @@ use PHPUnit\Framework\TestCase;
|
|||
class CsvDataInitTest extends TestCase
|
||||
{
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->csv_data_init = new CsvDataInit();
|
||||
}
|
||||
|
||||
public function testInitialize_csv_data()
|
||||
{
|
||||
|
||||
|
||||
$issue = [
|
||||
'repository' => ['name' => 'test'],
|
||||
'number' => 0,
|
||||
'title' => 'test',
|
||||
'html_url' => 'https://git.test.test/issue/0',
|
||||
'created_at' => '2024-08-14-11:00:00',
|
||||
'closed_at' => '2024-08-14-11:00:00',
|
||||
'labels' => [
|
||||
['name' => 'Priority/Low'],
|
||||
['name' => 'RequestBy/Customer'],
|
||||
['name' => 'Status/Resolved'],
|
||||
],
|
||||
'Kind' => '',
|
||||
'RequestBy' => '',
|
||||
'Priority' => '',
|
||||
];
|
||||
|
||||
$result = $this->csv_data_init->initialize_csv_data($issue);
|
||||
|
||||
$expected = [
|
||||
'Progetto' => 'test',
|
||||
'#' => 0,
|
||||
'Titolo' => 'test',
|
||||
'URL' => 'https://git.test.test/issue/0',
|
||||
'Aperto_il' => '2024-08-14-11:00:00',
|
||||
'Chiuso_il' => '2024-08-14-11:00:00',
|
||||
'Etichette' => 'Priority/Low,RequestBy/Customer,Status/Resolved,',
|
||||
'Kind' => '',
|
||||
'Request By' => '',
|
||||
'Priority' => ''
|
||||
];
|
||||
|
||||
$this->assertEquals($expected, $result);
|
||||
|
||||
}
|
||||
|
||||
public function testHandle_labels()
|
||||
{
|
||||
$array = [];
|
||||
$issue_labels = [
|
||||
[
|
||||
'name' => 'Kind: Bug'
|
||||
],
|
||||
[
|
||||
'name' => 'RequestBy: John Doe'
|
||||
],
|
||||
[
|
||||
'name' => 'Priority: High'
|
||||
],
|
||||
[
|
||||
'name' => 'Other Label'
|
||||
]
|
||||
];
|
||||
|
||||
// Call the handle_labels function
|
||||
$result = $this->csv_data_init->handle_labels($array, $issue_labels);
|
||||
|
||||
// Assert the expected output
|
||||
$this->assertArrayHasKey('Kind', $result);
|
||||
$this->assertEquals('Kind: Bug', $result['Kind']);
|
||||
|
||||
$this->assertArrayHasKey('Request By', $result);
|
||||
$this->assertEquals('RequestBy: John Doe', $result['Request By']);
|
||||
|
||||
$this->assertArrayHasKey('Priority', $result);
|
||||
$this->assertEquals('Priority: High', $result['Priority']);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue