Skip to content

Commit

Permalink
refactor: #81 use coding sdk project setting
Browse files Browse the repository at this point in the history
  • Loading branch information
sinkcup authored Oct 25, 2021
1 parent 0e20b8c commit beb492d
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 135 deletions.
42 changes: 0 additions & 42 deletions app/Coding/ProjectSetting.php

This file was deleted.

11 changes: 8 additions & 3 deletions app/Commands/IssueImportCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use Coding\Issue;
use Coding\Iteration;
use App\Coding\ProjectSetting;
use Coding\ProjectSetting;
use Exception;
use LaravelZero\Framework\Commands\Command;
use Rap2hpoutre\FastExcel\Facades\FastExcel;
Expand Down Expand Up @@ -46,6 +46,7 @@ public function handle(Issue $codingIssue, ProjectSetting $projectSetting, Itera
$this->setCodingApi();
$codingIssue->setToken($this->codingToken);
$iteration->setToken($this->codingToken);
$projectSetting->setToken($this->codingToken);

$filePath = $this->argument('file');
if (!file_exists($filePath)) {
Expand Down Expand Up @@ -75,7 +76,7 @@ public function handle(Issue $codingIssue, ProjectSetting $projectSetting, Itera
private function getIssueTypes(ProjectSetting $projectSetting, array $row): void
{
if (empty($this->issueTypes)) {
$result = $projectSetting->getIssueTypes($this->codingToken, $this->codingProjectUri);
$result = $projectSetting->getIssueTypes(['ProjectName' => $this->codingProjectUri]);
foreach ($result as $item) {
$this->issueTypes[$item['Name']] = $item;
}
Expand All @@ -90,7 +91,11 @@ private function getStatusId(ProjectSetting $projectSetting, string $issueTypeNa
if (!isset($this->issueTypeStatus[$issueTypeName])) {
$type = $this->issueTypes[$issueTypeName]['IssueType'];
$typeId = $this->issueTypes[$issueTypeName]['Id'];
$result = $projectSetting->getIssueTypeStatus($this->codingToken, $this->codingProjectUri, $type, $typeId);
$result = $projectSetting->getIssueStatus([
'ProjectName' => $this->codingProjectUri,
'IssueType' => $type,
'IssueTypeId' => $typeId
]);
foreach ($result as $item) {
$tmp = $item['IssueStatus'];
$this->issueTypeStatus[$issueTypeName][$tmp['Name']] = $tmp['Id'];
Expand Down
5 changes: 3 additions & 2 deletions app/Commands/ProjectGetIssueTypesCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace App\Commands;

use App\Coding\ProjectSetting;
use Coding\ProjectSetting;
use LaravelZero\Framework\Commands\Command;

class ProjectGetIssueTypesCommand extends Command
Expand Down Expand Up @@ -34,8 +34,9 @@ class ProjectGetIssueTypesCommand extends Command
public function handle(ProjectSetting $projectSetting): int
{
$this->setCodingApi();
$projectSetting->setToken($this->codingToken);

$result = $projectSetting->getIssueTypes($this->codingToken, $this->codingProjectUri);
$result = $projectSetting->getIssueTypes(['ProjectName' => $this->codingProjectUri]);

foreach ($result as $item) {
$this->info($item['Id'] . ' ' . $item['Name']);
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"ext-json": "*",
"ext-libxml": "*",
"ext-zip": "*",
"coding/sdk": "^0.2.0",
"coding/sdk": "^0.3.0",
"illuminate/log": "^8.0",
"laravel-fans/confluence": "^0.1.1",
"laravel-zero/framework": "^8.8",
Expand Down
14 changes: 7 additions & 7 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions tests/Feature/IssueImportCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use Coding\Issue;
use Coding\Iteration;
use App\Coding\ProjectSetting;
use Coding\ProjectSetting;
use Tests\TestCase;

class IssueImportCommandTest extends TestCase
Expand Down Expand Up @@ -37,7 +37,7 @@ public function testImportSuccess()
file_get_contents($this->dataDir . 'coding/' . 'DescribeProjectIssueStatusListResponse.json'),
true
)['Response']['ProjectIssueStatusList'];
$projectSettingMock->shouldReceive('getIssueTypeStatus')->times(5)->andReturn(
$projectSettingMock->shouldReceive('getIssueStatus')->times(5)->andReturn(
$requirementStatus,
$requirementStatus,
$requirementStatus,
Expand Down Expand Up @@ -87,7 +87,7 @@ public function testImportUserStorySuccess()
file_get_contents($this->dataDir . 'coding/' . 'DescribeProjectIssueTypeListResponse.json'),
true
)['Response']['IssueTypes']);
$projectSettingMock->shouldReceive('getIssueTypeStatus')->times(1)->andReturn(json_decode(
$projectSettingMock->shouldReceive('getIssueStatus')->times(1)->andReturn(json_decode(
file_get_contents($this->dataDir . 'coding/' . 'DescribeProjectIssueStatusListResponse.json'),
true
)['Response']['ProjectIssueStatusList']);
Expand Down Expand Up @@ -138,7 +138,7 @@ public function testImportSubTask()
file_get_contents($this->dataDir . 'coding/' . 'DescribeProjectIssueTypeListResponse.json'),
true
)['Response']['IssueTypes']);
$projectSettingMock->shouldReceive('getIssueTypeStatus')->times(2)->andReturn(json_decode(
$projectSettingMock->shouldReceive('getIssueStatus')->times(2)->andReturn(json_decode(
file_get_contents($this->dataDir . 'coding/' . 'DescribeProjectIssueStatusListResponse.json'),
true
)['Response']['ProjectIssueStatusList']);
Expand Down
2 changes: 1 addition & 1 deletion tests/Feature/ProjectGetIssueTypesCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Tests\Feature;

use App\Coding\ProjectSetting;
use Coding\ProjectSetting;
use Tests\TestCase;

class ProjectGetIssueTypesCommandTest extends TestCase
Expand Down
75 changes: 0 additions & 75 deletions tests/Unit/CodingProjectSettingTest.php

This file was deleted.

0 comments on commit beb492d

Please sign in to comment.