Skip to content

Commit 3562543

Browse files
committed
Support live testing for developers
1 parent 52b5bd6 commit 3562543

File tree

6 files changed

+48
-9
lines changed

6 files changed

+48
-9
lines changed

Diff for: CONTRIBUTING.md

+11
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,17 @@ Then run the unit tests as per normal.
3535

3636
N.B. you can study the `.github/workflows/tests.yml` file to see how we run these tests on our build servers by way of example.
3737

38+
### OPTIONAL: Creating a LIVE test locally
39+
40+
1. copy `phpunit.xml.dist` file into `phpunit.xml` file
41+
2. in the `phpunit.xml` file:
42+
* uncomment part, where `LIVE_TEST_ENDPOINT`, `LIVE_TEST_USERNAME` and `LIVE_TEST_PASSWORD` environment variables are defined
43+
* populate them with the corresponding values
44+
3. write the desired LIVE test in the `ApiTest::testLive` method (e.g. `$api->addWorklog('JRA-12', '12m');`)
45+
4. run it using `vendor/bin/phpunit --filter testLive` command
46+
5. confirm, that results in your Jira instance are as expected
47+
6. rollback changes to the `ApiTest::testLive` method before sending a PR
48+
3849
### Running Test Suite
3950

4051
Make sure that you don't break anything with your changes by running:

Diff for: phpunit.xml.dist

+11-8
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,18 @@
1414
</testsuite>
1515
</testsuites>
1616

17-
<filter>
18-
<whitelist>
19-
<directory>src</directory>
20-
</whitelist>
21-
</filter>
17+
<filter>
18+
<whitelist>
19+
<directory>src</directory>
20+
</whitelist>
21+
</filter>
2222

23-
<!--
24-
<php>
23+
<!--
24+
<php>
2525
<server name="REPO_URL" value="http://localhost/"/>
26-
</php>
26+
<server name="LIVE_TEST_ENDPOINT" value="https://site.atlassian.net/"/>
27+
<server name="LIVE_TEST_USERNAME" value=""/>
28+
<server name="LIVE_TEST_PASSWORD" value=""/>
29+
</php>
2730
-->
2831
</phpunit>

Diff for: phpunit10.xml.dist

+3
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
<!--
2424
<php>
2525
<server name="REPO_URL" value="http://localhost/"/>
26+
<server name="LIVE_TEST_ENDPOINT" value="https://site.atlassian.net/"/>
27+
<server name="LIVE_TEST_USERNAME" value=""/>
28+
<server name="LIVE_TEST_PASSWORD" value=""/>
2629
</php>
2730
-->
2831
</phpunit>

Diff for: phpunit7.xml.dist

+3
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222
<!--
2323
<php>
2424
<server name="REPO_URL" value="http://localhost/"/>
25+
<server name="LIVE_TEST_ENDPOINT" value="https://site.atlassian.net/"/>
26+
<server name="LIVE_TEST_USERNAME" value=""/>
27+
<server name="LIVE_TEST_PASSWORD" value=""/>
2528
</php>
2629
-->
2730
</phpunit>

Diff for: phpunit9.xml.dist

+3
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
<!--
2424
<php>
2525
<server name="REPO_URL" value="http://localhost/"/>
26+
<server name="LIVE_TEST_ENDPOINT" value="https://site.atlassian.net/"/>
27+
<server name="LIVE_TEST_USERNAME" value=""/>
28+
<server name="LIVE_TEST_PASSWORD" value=""/>
2629
</php>
2730
-->
2831
</phpunit>

Diff for: tests/Jira/ApiTest.php

+17-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
use chobie\Jira\Api;
77
use chobie\Jira\Api\Authentication\AuthenticationInterface;
8+
use chobie\Jira\Api\Authentication\Basic;
89
use chobie\Jira\Api\Result;
910
use chobie\Jira\IssueType;
1011
use Prophecy\Prophecy\ObjectProphecy;
@@ -495,6 +496,21 @@ public function testDeleteWorkLogWithCustomParams()
495496
$this->assertEquals(json_decode($response, true), $actual, 'The response is json-decoded.');
496497
}
497498

499+
public function testLive()
500+
{
501+
if ( empty($_SERVER['LIVE_TEST_ENDPOINT']) ) {
502+
$this->markTestSkipped('The "LIVE_TEST_ENDPOINT" environment variable not set.');
503+
}
504+
505+
$api = new Api(
506+
$_SERVER['LIVE_TEST_ENDPOINT'],
507+
new Basic($_SERVER['LIVE_TEST_USERNAME'], $_SERVER['LIVE_TEST_PASSWORD'])
508+
);
509+
510+
// Write you test here, but don't commit.
511+
$this->assertTrue(true);
512+
}
513+
498514
/**
499515
* Expects a particular client call.
500516
*
@@ -510,7 +526,7 @@ public function testDeleteWorkLogWithCustomParams()
510526
protected function expectClientCall(
511527
$method,
512528
$url,
513-
$data = array(),
529+
$data,
514530
$return_value,
515531
$is_file = false,
516532
$debug = false

0 commit comments

Comments
 (0)