Skip to content

Commit

Permalink
revised SprintService - add sample file(ref #496)
Browse files Browse the repository at this point in the history
  • Loading branch information
lesstif committed Jan 22, 2023
1 parent e210ede commit aa2c4f7
Showing 1 changed file with 88 additions and 0 deletions.
88 changes: 88 additions & 0 deletions tests/SPrintTest.php
Original file line number Diff line number Diff line change
@@ -1 +1,89 @@
<?php
namespace JiraRestApi\Test;

use DateInterval;
use DateTime;
use Exception;
use JiraRestApi\JiraException;
use JiraRestApi\Sprint\Sprint;
use JiraRestApi\Sprint\SprintService;
use PHPUnit\Framework\TestCase;
use JiraRestApi\Dumper;
use JiraRestApi\Issue\Reporter;

class SPrintTest extends TestCase
{
/**
* @test
*
*/
public function create_sprint() : int
{
$start = (new DateTime('NOW'))->add(DateInterval::createFromDateString('1 month 5 day'));

$sp = (new Sprint())
->setNameAsString("My Sprint 1")
->setGoalAsString("goal")
->setOriginBoardIdAsStringOrInt(3)
->setStartDateAsDateTime($start)
->setEndDateAsDateTime($start->add(DateInterval::createFromDateString('3 week')))
;

try {
$sps = new SprintService();

$sprint = $sps->createSprint($sp);

$this->assertNotNull($sprint->name);

return $sprint->id;

} catch (Exception $e) {
$this->fail('testSearch Failed : '.$e->getMessage());
}
}

/**
* @test
*
* @depends create_sprint
*
* @throws \JsonMapper_Exception
*/
public function get_sprints(int $sprintId) : int
{
try {
$sps = new SprintService();

$sprint = $sps->getSprint($sprintId);

$this->assertNotNull($sprint->name);
Dumper::dump($sprint);

return $sprintId;
} catch (Exception $e) {
$this->fail('testSearch Failed : '.$e->getMessage());
}
}

/**
* @test
* @depends get_sprints
*
* @param int $sprintId
* @return void
*/
public function get_issues_in_sprints(int $sprintId)
{
try {
$sps = new SprintService();

$sprint = $sps->getSprintIssues($sprintId);

$this->assertNotNull($sprint);
Dumper::dump($sprint);
} catch (Exception $e) {
$this->fail('testSearch Failed : '.$e->getMessage());
}
}
}

0 comments on commit aa2c4f7

Please sign in to comment.