Skip to content

Commit

Permalink
Merge pull request #1 from amritms/WCP-02
Browse files Browse the repository at this point in the history
WCP-02 adds tests
  • Loading branch information
amritms authored Jan 19, 2021
2 parents 26da859 + a2f87ae commit dabb081
Show file tree
Hide file tree
Showing 4 changed files with 446 additions and 21 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/test_runner.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: PHP Composer

on: [push, pull_request]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Validate composer.json and composer.lock
run: composer validate

- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v2
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-
- name: Install dependencies
if: steps.composer-cache.outputs.cache-hit != 'true'
run: composer install --prefer-dist --no-progress --no-suggest

# Add a test script to composer.json, for instance: "test": "vendor/bin/phpunit"
# Docs: https://getcomposer.org/doc/articles/scripts.md

# - name: Run test suite
# run: composer run-script test
33 changes: 16 additions & 17 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="vendor/autoload.php"
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
bootstrap="vendor/autoload.php"
backupGlobals="false"
backupStaticAttributes="false"
colors="true"
Expand All @@ -8,26 +9,24 @@
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false">
stopOnFailure="false"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage>
<include>
<directory suffix=".php">src/</directory>
</include>
<report>
<clover outputFile="build/logs/cover.xml"/>
<text outputFile="build/coverage.xml"/>
<html outputDirectory="build/html/"/>
</report>
</coverage>
<testsuites>
<testsuite name="Chuck Norris Test Suite">
<testsuite name="Waveapps Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory suffix=".php">src/</directory>
</whitelist>
</filter>
<logging>
<!-- <log type="tap" target="build/report.tap"/> -->
<log type="junit" target="build/report.junit.xml"/>
<!-- <log type="coverage-html" target="build/coverage" charset="UTF-8" yui="true" highlight="true"/> -->
<log type="coverage-text" target="build/coverage.txt"/>
<log type="coverage-clover" target="build/logs/clover.xml"/>
<junit outputFile="build/report.junit.xml"/>
</logging>
<php>
<env name="DB_CONNECTION" value="testing"/>

</php>
</phpunit>
8 changes: 4 additions & 4 deletions src/Waveapps.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class Waveapps
*/
private $responseBuilder;

public function __construct($graphqlUrl = null, $token = null, $businessId = null, array $config = [])
public function __construct($client = null, $graphqlUrl = null, $token = null, $businessId = null, array $config = [])
{
$this->config = $config;

Expand All @@ -37,10 +37,10 @@ public function __construct($graphqlUrl = null, $token = null, $businessId = nul
if (empty($this->url)) {
throw new Exception("Please provide wave app's graphql uri", 400);
}
$this->businessId = ($businessId ? $businessId : $config['businessId']);
$this->businessId = $businessId ? $businessId : $config['businessId'];

$this->client = new Client();
$this->url = $config['graphql_uri'];
$this->client = $client ?: new Client();
// $this->url = $config['graphql_uri'];
$this->headers = [
'Authorization' => 'Bearer ' . $this->token,
];
Expand Down
Loading

0 comments on commit dabb081

Please sign in to comment.