Skip to content
This repository was archived by the owner on Oct 17, 2023. It is now read-only.

Commit 8935f11

Browse files
authored
Fix CI and add Testing for other PHP versions (#116)
* Remove TravisCI & replace with Github Actions * keep travis-ci add other workflows * switch order of guzzle dependency * use matrix with highest/lowest composer version deps * add php deps * try fixing pagenotfound test * raise guzzle min to 6.3 to try fixing 7.1 build * use stages since these tests are account and integration based * add simple guid generation to test * bump version * bump version to 3.7.0
1 parent 0f67ce7 commit 8935f11

8 files changed

Lines changed: 61 additions & 19 deletions

File tree

.travis.yml

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,26 @@
11
language: php
2-
php:
3-
- 7.1
4-
before_install:
5-
- cp phpunit.xml.sample phpunit.xml
6-
- composer install
7-
script:
8-
- ./vendor/bin/phpunit
2+
jobs:
3+
include:
4+
- stage: php71-lowest
5+
php: 7.1
6+
env: dependencies=lowest
7+
script: ./vendor/bin/phpunit
8+
- stage: php72-lowest
9+
php: 7.2
10+
env: dependencies=lowest
11+
script: ./vendor/bin/phpunit
12+
- stage: php72
13+
php: 7.2
14+
script: ./vendor/bin/phpunit
15+
- stage: php73
16+
php: 7.3
17+
script: ./vendor/bin/phpunit
18+
- stage: php74
19+
php: 7.4
20+
script: ./vendor/bin/phpunit
21+
22+
before_script:
23+
- composer self-update -q
24+
- if [ -z "$dependencies" ]; then composer install; fi;
25+
- if [ "$dependencies" = "lowest" ]; then composer update --prefer-lowest -n; fi;
26+
- if [ "$dependencies" = "highest" ]; then composer update -n; fi;

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ In order to pass the unit tests, you will need:
311311
312312
### To run the tests
313313
314-
- Copy file `phpunit.xml.sample` to `phpunit.xml`
314+
- Copy file `phpunit.xml.dist` to `phpunit.xml`
315315
- Edit the new file and enter your values for `API_KEY`, `CLIENT_ID`, `CLIENT_SECRET`, `CALLBACK_URL`, `API_URL`, AND `OAUTH_TOKEN_URL`
316316
- Run `./vendor/bin/phpunit`
317317

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@
1717
"phpunit/phpunit": "7.3.*"
1818
},
1919
"require": {
20-
"guzzlehttp/guzzle": "^7.0|^6.2"
20+
"guzzlehttp/guzzle": "^6.3|^7.0"
2121
}
2222
}

library/HelloSign/Client.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
class Client
4242
{
4343

44-
const VERSION = '3.6.0';
44+
const VERSION = '3.7.0';
4545

4646
const API_URL = "https://api.hellosign.com/v3/";
4747

library/HelloSign/Test/ApiAppTest.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@
3030

3131
class ApiAppTest extends AbstractTest
3232
{
33+
private function generateApiAppName(string $prefix): string
34+
{
35+
$guid = TestUtils::generateGuid(8);
36+
return $prefix . $guid;
37+
}
38+
3339
/**
3440
* @expectedException HelloSign\Error
3541
* @expectedExceptionMessage An app with the same name already exists
@@ -40,7 +46,7 @@ public function testCreateApiApp()
4046
$wl = array('primary_button_color' => '#626567', 'primary_button_text_color' => '#ffffff');
4147
$wl = json_encode($wl);
4248

43-
$name = "Test" . rand(1, 2000);
49+
$name = $this->generateApiAppName('Test');
4450
$domain = "www.testdomain.com";
4551
$callback = $_ENV['CALLBACK_URL'];
4652
$logo = __DIR__ . "/logo.jpg";
@@ -75,7 +81,7 @@ public function testCreateApiApp()
7581
*/
7682
public function testCreateOauthApiApp()
7783
{
78-
$name = "Test Oauth" . rand(1, 2000);
84+
$name = $this->generateApiAppName('Test Oauth');
7985
$domain = "www.testdomain.com";
8086
$callback = $_ENV['CALLBACK_URL'];
8187
$logo = __DIR__ . "/logo.jpg";
@@ -104,7 +110,7 @@ public function testCreateOauthApiApp()
104110
public function testUpdateApiApp()
105111
{
106112

107-
$name = "Test" . rand(1, 2000);
113+
$name = $this->generateApiAppName('Test');
108114
$domain = "www.testdomain.com";
109115

110116
$app = new ApiApp;
@@ -131,7 +137,7 @@ public function testUpdateApiApp()
131137
*/
132138
public function testGetApiApp()
133139
{
134-
$name = "Test" . rand(1, 2000);
140+
$name = $this->generateApiAppName('Test');
135141
$domain = "www.testdomain.com";
136142
$callback_url = $_ENV['CALLBACK_URL'];
137143

library/HelloSign/Test/TemplateTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class TemplateTest extends AbstractTest
4141
*/
4242
public function testGetTemplatesWithPageNotFound()
4343
{
44-
$templates = $this->client->getTemplates(9999);
44+
$templates = $this->client->getTemplates(9999, 1);
4545
}
4646

4747
/**
@@ -187,7 +187,7 @@ public function testUpdateTemplateFiles()
187187
$templates = $this->client->getTemplates();
188188
$template_id = $templates[0]->getId();
189189
$client_id = $_ENV['CLIENT_ID'];
190-
190+
191191
$request = new \HelloSign\Template();
192192
$request->setClientId($client_id);
193193
$request->addFile(__DIR__ . '/nda.docx');
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
namespace HelloSign\Test;
4+
5+
class TestUtils
6+
{
7+
/**
8+
* @param int|null $length
9+
* @return string
10+
*/
11+
public static function generateGuid(?int $length = 40): string
12+
{
13+
$bytes = random_bytes((int) ceil($length / 2));
14+
$guid = bin2hex($bytes);
15+
16+
return substr($guid, 0, $length);
17+
}
18+
}
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
</testsuite>
77
</testsuites>
88
<php>
9-
<env name="API_KEY" value="9dc85fe9ef819a2dc5aac48fd5b951ee2f5b6528c26dd398438fce6b355cb075"/>
10-
<env name="CLIENT_ID" value="457519f7a1be8feca9f3533c00b98596"/>
11-
<env name="CLIENT_SECRET" value="4798f37830ace2866b2ca5d19dd3ede5"/>
9+
<env name="API_KEY" value="REPLACE_WITH_YOUR_KEY"/>
10+
<env name="CLIENT_ID" value="REPLACE_WITH_YOUR_CLIENT_ID"/>
11+
<env name="CLIENT_SECRET" value="REPLACE_WITH_YOUR_CLIENT_SECRET"/>
1212
<env name="CALLBACK_URL" value="http://example.com/callback"/>
1313
<env name="API_URL" value="https://api.hellosign.com/v3/"/>
1414
<env name="OAUTH_TOKEN_URL" value="https://app.hellosign.com/oauth/token"/>

0 commit comments

Comments
 (0)