mirror of
https://github.com/SkillDisplay/PHPToolKit.git
synced 2024-12-24 03:26:08 +01:00
Add tests and execute via GitHub Actions
This commit is contained in:
parent
f765b1fbff
commit
619436a2fd
6 changed files with 2383 additions and 3 deletions
51
.github/workflows/ci.yaml
vendored
Normal file
51
.github/workflows/ci.yaml
vendored
Normal file
|
@ -0,0 +1,51 @@
|
|||
name: CI
|
||||
on: [push]
|
||||
jobs:
|
||||
check-composer:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Validate composer.json
|
||||
run: composer validate
|
||||
|
||||
php-linting:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
php-version:
|
||||
- 7.4
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Install PHP
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: "${{ matrix.php-version }}"
|
||||
|
||||
- name: PHP lint
|
||||
run: "find *.php src tests -name '*.php' -print0 | xargs -0 -n 1 -P 4 php -l"
|
||||
|
||||
tests:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Get Composer Cache Directory
|
||||
id: composer-cache
|
||||
run: |
|
||||
echo "::set-output name=dir::$(composer config cache-files-dir)"
|
||||
|
||||
- uses: actions/cache@v1
|
||||
with:
|
||||
path: ${{ steps.composer-cache.outputs.dir }}
|
||||
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-composer-
|
||||
|
||||
- name: Install dependencies
|
||||
run: composer install --prefer-dist --no-progress --no-suggest
|
||||
|
||||
- name: PHPUnit Tests
|
||||
run: ./vendor/bin/phpunit --testdox
|
|
@ -18,5 +18,14 @@
|
|||
"psr-4": {
|
||||
"SkillDisplay\\PHPToolKit\\": "src/"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"SkillDisplay\\PHPToolKit\\Tests\\": "tests/"
|
||||
}
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^9.3",
|
||||
"phpspec/prophecy-phpunit": "^2.0"
|
||||
}
|
||||
}
|
||||
|
|
2012
composer.lock
generated
2012
composer.lock
generated
File diff suppressed because it is too large
Load diff
30
phpunit.xml.dist
Normal file
30
phpunit.xml.dist
Normal file
|
@ -0,0 +1,30 @@
|
|||
<?xml version="1.0"?>
|
||||
<phpunit
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
|
||||
backupGlobals="false"
|
||||
backupStaticAttributes="false"
|
||||
colors="true"
|
||||
convertErrorsToExceptions="true"
|
||||
convertWarningsToExceptions="true"
|
||||
forceCoversAnnotation="false"
|
||||
processIsolation="false"
|
||||
stopOnError="false"
|
||||
stopOnFailure="false"
|
||||
stopOnIncomplete="false"
|
||||
stopOnSkipped="false"
|
||||
verbose="false"
|
||||
>
|
||||
|
||||
<testsuites>
|
||||
<testsuite name="unit">
|
||||
<directory>tests/Unit/</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
|
||||
<coverage>
|
||||
<include>
|
||||
<directory suffix=".php">src</directory>
|
||||
</include>
|
||||
</coverage>
|
||||
</phpunit>
|
95
tests/Unit/Configuration/SettingsTest.php
Normal file
95
tests/Unit/Configuration/SettingsTest.php
Normal file
|
@ -0,0 +1,95 @@
|
|||
<?php
|
||||
|
||||
namespace SkillDisplay\PHPToolKit\Tests\Unit\Configuration;
|
||||
|
||||
use SkillDisplay\PHPToolKit\Configuration\Settings;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @covers SkillDisplay\PHPToolKit\Configuration\Settings
|
||||
*/
|
||||
class SettingsTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function canBeCreatedWithoutAnyValues()
|
||||
{
|
||||
$subject = new Settings('none');
|
||||
static::assertInstanceOf(
|
||||
Settings::class,
|
||||
$subject
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function returnsExpectedValuesWhenCreatedWithoutAnyValues()
|
||||
{
|
||||
$subject = new Settings('none');
|
||||
|
||||
static::assertSame('none', $subject->getApiKey());
|
||||
static::assertSame(0, $subject->getVerifierID());
|
||||
static::assertSame('', $subject->getUserSecret());
|
||||
static::assertSame('https://www.skilldisplay.eu', $subject->getAPIUrl());
|
||||
static::assertSame('https://my.skilldisplay.eu', $subject->getMySkillDisplayUrl());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function canBeCreatedWithApiKey()
|
||||
{
|
||||
$subject = new Settings('---YOUR-API-KEY---');
|
||||
static::assertInstanceOf(
|
||||
Settings::class,
|
||||
$subject
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function returnsExpectedValuesWhenCreatedWithApiKey()
|
||||
{
|
||||
$subject = new Settings('---YOUR-API-KEY---');
|
||||
|
||||
static::assertSame('---YOUR-API-KEY---', $subject->getApiKey());
|
||||
static::assertSame(0, $subject->getVerifierID());
|
||||
static::assertSame('', $subject->getUserSecret());
|
||||
static::assertSame('https://www.skilldisplay.eu', $subject->getAPIUrl());
|
||||
static::assertSame('https://my.skilldisplay.eu', $subject->getMySkillDisplayUrl());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function returnsVerifierIdWhenProvided()
|
||||
{
|
||||
$subject = new Settings('none', 10);
|
||||
|
||||
static::assertSame(10, $subject->getVerifierID());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function returnsUserSecretWhenProvided()
|
||||
{
|
||||
$subject = new Settings('none', 0, '---USER-SECRET---');
|
||||
|
||||
static::assertSame('---USER-SECRET---', $subject->getUserSecret());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function returnsUrlsWithProvidedDomain()
|
||||
{
|
||||
$subject = new Settings('none', 0, '', 'example.com');
|
||||
|
||||
static::assertSame('https://example.com', $subject->getAPIUrl());
|
||||
static::assertSame('https://my.example.com', $subject->getMySkillDisplayUrl());
|
||||
}
|
||||
}
|
189
tests/Unit/Verification/LinkTest.php
Normal file
189
tests/Unit/Verification/LinkTest.php
Normal file
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue