diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index bbb751b..7a4d3ff 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -35,6 +35,17 @@ Then run the unit tests as per normal. 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. +### OPTIONAL: Creating a LIVE test locally + +1. copy `phpunit.xml.dist` file into `phpunit.xml` file +2. in the `phpunit.xml` file: + * uncomment part, where `LIVE_TEST_ENDPOINT`, `LIVE_TEST_USERNAME` and `LIVE_TEST_PASSWORD` environment variables are defined + * populate them with the corresponding values +3. write the desired LIVE test in the `ApiTest::testLive` method (e.g. `$api->addWorklog('JRA-12', '12m');`) +4. run it using `vendor/bin/phpunit --filter testLive` command +5. confirm, that results in your Jira instance are as expected +6. rollback changes to the `ApiTest::testLive` method before sending a PR + ### Running Test Suite Make sure that you don't break anything with your changes by running: diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 18483cf..4fcad42 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -14,15 +14,18 @@ - - - src - - + + + src + + - diff --git a/phpunit10.xml.dist b/phpunit10.xml.dist index 23e03cf..f2cc825 100644 --- a/phpunit10.xml.dist +++ b/phpunit10.xml.dist @@ -23,6 +23,9 @@ diff --git a/phpunit7.xml.dist b/phpunit7.xml.dist index d958cd7..3bb403a 100644 --- a/phpunit7.xml.dist +++ b/phpunit7.xml.dist @@ -22,6 +22,9 @@ diff --git a/phpunit9.xml.dist b/phpunit9.xml.dist index 9d4781d..eedc6d2 100644 --- a/phpunit9.xml.dist +++ b/phpunit9.xml.dist @@ -23,6 +23,9 @@ diff --git a/tests/Jira/ApiTest.php b/tests/Jira/ApiTest.php index c62c1c0..2821eeb 100644 --- a/tests/Jira/ApiTest.php +++ b/tests/Jira/ApiTest.php @@ -5,6 +5,7 @@ use chobie\Jira\Api; use chobie\Jira\Api\Authentication\AuthenticationInterface; +use chobie\Jira\Api\Authentication\Basic; use chobie\Jira\Api\Result; use chobie\Jira\IssueType; use Prophecy\Prophecy\ObjectProphecy; @@ -495,6 +496,21 @@ public function testDeleteWorkLogWithCustomParams() $this->assertEquals(json_decode($response, true), $actual, 'The response is json-decoded.'); } + public function testLive() + { + if ( empty($_SERVER['LIVE_TEST_ENDPOINT']) ) { + $this->markTestSkipped('The "LIVE_TEST_ENDPOINT" environment variable not set.'); + } + + $api = new Api( + $_SERVER['LIVE_TEST_ENDPOINT'], + new Basic($_SERVER['LIVE_TEST_USERNAME'], $_SERVER['LIVE_TEST_PASSWORD']) + ); + + // Write you test here, but don't commit. + $this->assertTrue(true); + } + /** * Expects a particular client call. * @@ -510,7 +526,7 @@ public function testDeleteWorkLogWithCustomParams() protected function expectClientCall( $method, $url, - $data = array(), + $data, $return_value, $is_file = false, $debug = false