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

Commit

Permalink
Fix CI and add Testing for other PHP versions (#116)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
jspaetzel committed Jun 1, 2021
1 parent 0f67ce7 commit 8935f11
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 19 deletions.
32 changes: 25 additions & 7 deletions .travis.yml
@@ -1,8 +1,26 @@
language: php
php:
- 7.1
before_install:
- cp phpunit.xml.sample phpunit.xml
- composer install
script:
- ./vendor/bin/phpunit
jobs:
include:
- stage: php71-lowest
php: 7.1
env: dependencies=lowest
script: ./vendor/bin/phpunit
- stage: php72-lowest
php: 7.2
env: dependencies=lowest
script: ./vendor/bin/phpunit
- stage: php72
php: 7.2
script: ./vendor/bin/phpunit
- stage: php73
php: 7.3
script: ./vendor/bin/phpunit
- stage: php74
php: 7.4
script: ./vendor/bin/phpunit

before_script:
- composer self-update -q
- if [ -z "$dependencies" ]; then composer install; fi;
- if [ "$dependencies" = "lowest" ]; then composer update --prefer-lowest -n; fi;
- if [ "$dependencies" = "highest" ]; then composer update -n; fi;
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -311,7 +311,7 @@ In order to pass the unit tests, you will need:

### To run the tests

- Copy file `phpunit.xml.sample` to `phpunit.xml`
- Copy file `phpunit.xml.dist` to `phpunit.xml`
- Edit the new file and enter your values for `API_KEY`, `CLIENT_ID`, `CLIENT_SECRET`, `CALLBACK_URL`, `API_URL`, AND `OAUTH_TOKEN_URL`
- Run `./vendor/bin/phpunit`

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Expand Up @@ -17,6 +17,6 @@
"phpunit/phpunit": "7.3.*"
},
"require": {
"guzzlehttp/guzzle": "^7.0|^6.2"
"guzzlehttp/guzzle": "^6.3|^7.0"
}
}
2 changes: 1 addition & 1 deletion library/HelloSign/Client.php
Expand Up @@ -41,7 +41,7 @@
class Client
{

const VERSION = '3.6.0';
const VERSION = '3.7.0';

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

Expand Down
14 changes: 10 additions & 4 deletions library/HelloSign/Test/ApiAppTest.php
Expand Up @@ -30,6 +30,12 @@

class ApiAppTest extends AbstractTest
{
private function generateApiAppName(string $prefix): string
{
$guid = TestUtils::generateGuid(8);
return $prefix . $guid;
}

/**
* @expectedException HelloSign\Error
* @expectedExceptionMessage An app with the same name already exists
Expand All @@ -40,7 +46,7 @@ public function testCreateApiApp()
$wl = array('primary_button_color' => '#626567', 'primary_button_text_color' => '#ffffff');
$wl = json_encode($wl);

$name = "Test" . rand(1, 2000);
$name = $this->generateApiAppName('Test');
$domain = "www.testdomain.com";
$callback = $_ENV['CALLBACK_URL'];
$logo = __DIR__ . "/logo.jpg";
Expand Down Expand Up @@ -75,7 +81,7 @@ public function testCreateApiApp()
*/
public function testCreateOauthApiApp()
{
$name = "Test Oauth" . rand(1, 2000);
$name = $this->generateApiAppName('Test Oauth');
$domain = "www.testdomain.com";
$callback = $_ENV['CALLBACK_URL'];
$logo = __DIR__ . "/logo.jpg";
Expand Down Expand Up @@ -104,7 +110,7 @@ public function testCreateOauthApiApp()
public function testUpdateApiApp()
{

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

$app = new ApiApp;
Expand All @@ -131,7 +137,7 @@ public function testUpdateApiApp()
*/
public function testGetApiApp()
{
$name = "Test" . rand(1, 2000);
$name = $this->generateApiAppName('Test');
$domain = "www.testdomain.com";
$callback_url = $_ENV['CALLBACK_URL'];

Expand Down
4 changes: 2 additions & 2 deletions library/HelloSign/Test/TemplateTest.php
Expand Up @@ -41,7 +41,7 @@ class TemplateTest extends AbstractTest
*/
public function testGetTemplatesWithPageNotFound()
{
$templates = $this->client->getTemplates(9999);
$templates = $this->client->getTemplates(9999, 1);
}

/**
Expand Down Expand Up @@ -187,7 +187,7 @@ public function testUpdateTemplateFiles()
$templates = $this->client->getTemplates();
$template_id = $templates[0]->getId();
$client_id = $_ENV['CLIENT_ID'];

$request = new \HelloSign\Template();
$request->setClientId($client_id);
$request->addFile(__DIR__ . '/nda.docx');
Expand Down
18 changes: 18 additions & 0 deletions library/HelloSign/Test/TestUtils.php
@@ -0,0 +1,18 @@
<?php

namespace HelloSign\Test;

class TestUtils
{
/**
* @param int|null $length
* @return string
*/
public static function generateGuid(?int $length = 40): string
{
$bytes = random_bytes((int) ceil($length / 2));
$guid = bin2hex($bytes);

return substr($guid, 0, $length);
}
}
6 changes: 3 additions & 3 deletions phpunit.xml.sample → phpunit.xml.dist
Expand Up @@ -6,9 +6,9 @@
</testsuite>
</testsuites>
<php>
<env name="API_KEY" value="9dc85fe9ef819a2dc5aac48fd5b951ee2f5b6528c26dd398438fce6b355cb075"/>
<env name="CLIENT_ID" value="457519f7a1be8feca9f3533c00b98596"/>
<env name="CLIENT_SECRET" value="4798f37830ace2866b2ca5d19dd3ede5"/>
<env name="API_KEY" value="REPLACE_WITH_YOUR_KEY"/>
<env name="CLIENT_ID" value="REPLACE_WITH_YOUR_CLIENT_ID"/>
<env name="CLIENT_SECRET" value="REPLACE_WITH_YOUR_CLIENT_SECRET"/>
<env name="CALLBACK_URL" value="http://example.com/callback"/>
<env name="API_URL" value="https://api.hellosign.com/v3/"/>
<env name="OAUTH_TOKEN_URL" value="https://app.hellosign.com/oauth/token"/>
Expand Down

0 comments on commit 8935f11

Please sign in to comment.