Skip to content

Commit 7fa0092

Browse files
committed
Support live testing for developers
1 parent 3cd00f8 commit 7fa0092

File tree

3 files changed

+36
-6
lines changed

3 files changed

+36
-6
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 `.travis.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

+8-5
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,18 @@
2121
</testsuite>
2222
</testsuites>
2323

24-
<filter>
25-
<whitelist>
26-
<directory>src</directory>
27-
</whitelist>
28-
</filter>
24+
<filter>
25+
<whitelist>
26+
<directory>src</directory>
27+
</whitelist>
28+
</filter>
2929

3030
<!--
3131
<php>
3232
<server name="REPO_URL" value="http://localhost/"/>
33+
<server name="LIVE_TEST_ENDPOINT" value="https://site.atlassian.net/"/>
34+
<server name="LIVE_TEST_USERNAME" value=""/>
35+
<server name="LIVE_TEST_PASSWORD" value=""/>
3336
</php>
3437
-->
3538

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 PHPUnit\Framework\TestCase;
@@ -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)