Skip to content

Commit dabb081

Browse files
authored
Merge pull request #1 from amritms/WCP-02
WCP-02 adds tests
2 parents 26da859 + a2f87ae commit dabb081

File tree

4 files changed

+446
-21
lines changed

4 files changed

+446
-21
lines changed

.github/workflows/test_runner.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: PHP Composer
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
build:
7+
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- uses: actions/checkout@v2
12+
13+
- name: Validate composer.json and composer.lock
14+
run: composer validate
15+
16+
- name: Cache Composer packages
17+
id: composer-cache
18+
uses: actions/cache@v2
19+
with:
20+
path: vendor
21+
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
22+
restore-keys: |
23+
${{ runner.os }}-php-
24+
25+
- name: Install dependencies
26+
if: steps.composer-cache.outputs.cache-hit != 'true'
27+
run: composer install --prefer-dist --no-progress --no-suggest
28+
29+
# Add a test script to composer.json, for instance: "test": "vendor/bin/phpunit"
30+
# Docs: https://getcomposer.org/doc/articles/scripts.md
31+
32+
# - name: Run test suite
33+
# run: composer run-script test

phpunit.xml.dist

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit bootstrap="vendor/autoload.php"
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
bootstrap="vendor/autoload.php"
34
backupGlobals="false"
45
backupStaticAttributes="false"
56
colors="true"
@@ -8,26 +9,24 @@
89
convertNoticesToExceptions="true"
910
convertWarningsToExceptions="true"
1011
processIsolation="false"
11-
stopOnFailure="false">
12+
stopOnFailure="false"
13+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
14+
<coverage>
15+
<include>
16+
<directory suffix=".php">src/</directory>
17+
</include>
18+
<report>
19+
<clover outputFile="build/logs/cover.xml"/>
20+
<text outputFile="build/coverage.xml"/>
21+
<html outputDirectory="build/html/"/>
22+
</report>
23+
</coverage>
1224
<testsuites>
13-
<testsuite name="Chuck Norris Test Suite">
25+
<testsuite name="Waveapps Test Suite">
1426
<directory>tests</directory>
1527
</testsuite>
1628
</testsuites>
17-
<filter>
18-
<whitelist>
19-
<directory suffix=".php">src/</directory>
20-
</whitelist>
21-
</filter>
2229
<logging>
23-
<!-- <log type="tap" target="build/report.tap"/> -->
24-
<log type="junit" target="build/report.junit.xml"/>
25-
<!-- <log type="coverage-html" target="build/coverage" charset="UTF-8" yui="true" highlight="true"/> -->
26-
<log type="coverage-text" target="build/coverage.txt"/>
27-
<log type="coverage-clover" target="build/logs/clover.xml"/>
30+
<junit outputFile="build/report.junit.xml"/>
2831
</logging>
29-
<php>
30-
<env name="DB_CONNECTION" value="testing"/>
31-
32-
</php>
3332
</phpunit>

src/Waveapps.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class Waveapps
2424
*/
2525
private $responseBuilder;
2626

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

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

42-
$this->client = new Client();
43-
$this->url = $config['graphql_uri'];
42+
$this->client = $client ?: new Client();
43+
// $this->url = $config['graphql_uri'];
4444
$this->headers = [
4545
'Authorization' => 'Bearer ' . $this->token,
4646
];

0 commit comments

Comments
 (0)