Skip to content

Commit 8cccce6

Browse files
committed
Support live testing for developers
1 parent c94011b commit 8cccce6

File tree

6 files changed

+48
-9
lines changed

6 files changed

+48
-9
lines changed

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:

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>

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>

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>

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>

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;
@@ -392,6 +393,21 @@ public function testDeleteWorkLogWithCustomParams()
392393
$this->assertEquals(json_decode($response, true), $actual, 'The response is json-decoded.');
393394
}
394395

396+
public function testLive()
397+
{
398+
if ( empty($_SERVER['LIVE_TEST_ENDPOINT']) ) {
399+
$this->markTestSkipped('The "LIVE_TEST_ENDPOINT" environment variable not set.');
400+
}
401+
402+
$api = new Api(
403+
$_SERVER['LIVE_TEST_ENDPOINT'],
404+
new Basic($_SERVER['LIVE_TEST_USERNAME'], $_SERVER['LIVE_TEST_PASSWORD'])
405+
);
406+
407+
// Write you test here, but don't commit.
408+
$this->assertTrue(true);
409+
}
410+
395411
/**
396412
* Expects a particular client call.
397413
*
@@ -407,7 +423,7 @@ public function testDeleteWorkLogWithCustomParams()
407423
protected function expectClientCall(
408424
$method,
409425
$url,
410-
$data = array(),
426+
$data,
411427
$return_value,
412428
$is_file = false,
413429
$debug = false

0 commit comments

Comments
 (0)