Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 31 additions & 2 deletions .github/workflows/Tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,39 @@ jobs:
strategy:
fail-fast: false
matrix:
php: [5.6, 7.0, 7.1, 7.2, 7.3, 7.4, 8.0, 8.1, 8.2, 8.3]
php: [8.1, 8.2, 8.3]
experimental: [false]
composer-extra: ['']
phpunit-extra: ['']
include:
- php: 5.6
experimental: false
composer-extra: ''
phpunit-extra: '--verbose'
- php: 7.0
experimental: false
composer-extra: ''
phpunit-extra: '--verbose'
- php: 7.1
experimental: false
composer-extra: ''
phpunit-extra: '--verbose'
- php: 7.2
experimental: false
composer-extra: ''
phpunit-extra: '--verbose'
- php: 7.3
experimental: false
composer-extra: ''
phpunit-extra: '--verbose'
- php: 7.4
experimental: false
composer-extra: ''
phpunit-extra: '--verbose'
- php: 8.0
experimental: false
composer-extra: ''
phpunit-extra: '--verbose'
- php: 8.4
experimental: true
composer-extra: '--ignore-platform-req=php+'
Expand Down Expand Up @@ -57,7 +86,7 @@ jobs:
vendor/bin/phpmd src,tests xml build/config/phpmd.xml

- name: Run PHPUnit
run: vendor/bin/phpunit --verbose
run: vendor/bin/phpunit ${{ matrix.phpunit-extra }}

- name: Upload Coveralls coverage
if: env.ACT != 'true'
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
},
"require-dev": {
"ext-curl": "*",
"phpunit/phpunit": "^5.7 | ^6.0 | ^7.0 | ^8.0 | ^9.0",
"phpunit/phpunit": "^5.7 | ^6.0 | ^7.0 | ^8.0 | ^9.0 | ^10.0 | ^11.0",
"phpunit/php-invoker": "*",
"phpmd/phpmd": "@stable",
"squizlabs/php_codesniffer": "3.*@stable",
Expand Down
23 changes: 20 additions & 3 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,30 @@
processIsolation="false"
stopOnFailure="false">
<testsuites>
<testsuite name="GameQ v3 Test Suite">
<directory suffix=".php">./tests/</directory>
<testsuite name="GameQ General">
<directory suffix=".php">tests/General</directory>
<exclude>tests/General/TestCase.php</exclude>
</testsuite>
<testsuite name="GameQ Queries">
<directory suffix=".php">tests/Query</directory>
<exclude>tests/Query/TestCase.php</exclude>
</testsuite>
<testsuite name="GameQ Filters">
<directory suffix=".php">tests/Filters</directory>
<exclude>tests/Filters/TestCase.php</exclude>
</testsuite>
<testsuite name="GameQ Protocols">
<directory suffix=".php">tests/Protocols</directory>
<exclude>tests/Protocols/TestCase.php</exclude>
</testsuite>
<testsuite name="GameQ Issues">
<directory suffix=".php">tests/Issues</directory>
<exclude>tests/Issues/TestCase.php</exclude>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory>./src</directory>
<directory>src</directory>
</whitelist>
</filter>
<logging>
Expand Down
57 changes: 1 addition & 56 deletions tests/Filters/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,68 +18,13 @@

namespace GameQ\Tests\Filters;

use GameQ\Tests\TestBase;

/**
* Class for testing Filters Base
*
* @package GameQ\Tests\Filters
*/
class Base extends TestBase
class Base extends TestCase
{
/**
* Load up the provider data for the specific filter type
*
* @return array
*/
public function loadData()
{
// Explode the class that called to avoid strict error
$class = explode('\\', get_called_class());

// Determine the folder to grab the provider files and results from
$providersLookup = sprintf('%s/Providers/%s/', __DIR__, array_pop($class));

// Init the return array
$providers = [ ];

// Grab all of the test files for this filter
$files = new \DirectoryIterator($providersLookup);

// Iterate over the files in this path
foreach ($files as $fileinfo) {
// Skip if we can't read or is dotfile
if (!$fileinfo->isReadable() || !$fileinfo->isFile()) {
continue;
}

// Split the filename
list($protocol, $index) = explode('_', $fileinfo->getFilename());

unset($index);

// Get the data
if (($data = json_decode(file_get_contents($fileinfo->getRealPath()), true)) === null
&& json_last_error() !== JSON_ERROR_NONE
) {
// Skip
continue;
}

// Add the provider
$providers[] = [
$protocol,
$data['raw'],
$data['filtered']
];
}

// Clear some memory
unset($files, $fileinfo, $providersLookup);

return $providers;
}

// Real Base tests here

/**
Expand Down
80 changes: 80 additions & 0 deletions tests/Filters/TestCase.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<?php
/**
* This file is part of GameQ.
*
* GameQ is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* GameQ is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

namespace GameQ\Tests\Filters;

/**
* Class for testing Filters
*
* @package GameQ\Tests\Filters
*/
abstract class TestCase extends \GameQ\Tests\TestCase
{
/**
* Load up the provider data for the specific filter type
*
* @return array
*/
public static function loadData()
{
// Explode the class that called to avoid strict error
$class = explode('\\', get_called_class());

// Determine the folder to grab the provider files and results from
$providersLookup = sprintf('%s/Providers/%s/', __DIR__, array_pop($class));

// Init the return array
$providers = [ ];

// Grab all of the test files for this filter
$files = new \DirectoryIterator($providersLookup);

// Iterate over the files in this path
foreach ($files as $fileinfo) {
// Skip if we can't read or is dotfile
if (!$fileinfo->isReadable() || !$fileinfo->isFile()) {
continue;
}

// Split the filename
list($protocol, $index) = explode('_', $fileinfo->getFilename());

unset($index);

// Get the data
if (($data = json_decode(file_get_contents($fileinfo->getRealPath()), true)) === null
&& json_last_error() !== JSON_ERROR_NONE
) {
// Skip
continue;
}

// Add the provider
$providers[] = [
$protocol,
$data['raw'],
$data['filtered']
];
}

// Clear some memory
unset($files, $fileinfo, $providersLookup);

return $providers;
}
}
6 changes: 3 additions & 3 deletions tests/Buffer.php → tests/General/Buffer.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

namespace GameQ\Tests;
namespace GameQ\Tests\General;

/**
* Buffer test class
*
* @package GameQ\Tests
*/
class Buffer extends TestBase
class Buffer extends TestCase
{
/**
* Build a mock Buffer
Expand All @@ -44,7 +44,7 @@ protected function buildBuffer($data, $number_type = 'm')
*
* @return array
*/
public function integerDataProvider()
public static function integerDataProvider()
{
// Make the base path for the data to test since it has to be in ascii form
$basePath = sprintf('%s/Providers/Buffer', __DIR__);
Expand Down
12 changes: 6 additions & 6 deletions tests/GameQ.php → tests/General/GameQ.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

namespace GameQ\Tests;
namespace GameQ\Tests\General;

/**
* GameQ tests class
*
* @package GameQ\Tests
*/
class GameQ extends TestBase
class GameQ extends TestCase
{
/**
* Holds stub on setup
Expand Down Expand Up @@ -116,15 +116,15 @@ public function testAddServer()
public function testAddServersFromFiles()
{
// Test single file
$this->stub->addServersFromFiles(__DIR__ . '/Protocols/Providers/server_list1.json');
$this->stub->addServersFromFiles(__DIR__ . '/Providers/GameQ/server_list1.json');

$this->assertCount(2, $this->stub->getServers());

$this->stub->clearServers();

// Test adding from json array of files
$this->stub->addServersFromFiles([
__DIR__ . '/Protocols/Providers/server_list1.json',
__DIR__ . '/Providers/GameQ/server_list1.json',
]);

$this->assertCount(2, $this->stub->getServers());
Expand All @@ -133,7 +133,7 @@ public function testAddServersFromFiles()

// Test adding bad file
$this->stub->addServersFromFiles([
__DIR__ . '/Protocols/Providers/server_list_bad.json',
__DIR__ . '/Providers/GameQ/server_list_bad.json',
]);

// No servers should exist
Expand All @@ -142,7 +142,7 @@ public function testAddServersFromFiles()
$this->stub->clearServers();

// Test inaccessible file
$this->stub->addServersFromFiles(__DIR__ . '/Protocols/Providers/server_listDoesnotexist.json');
$this->stub->addServersFromFiles(__DIR__ . '/Providers/GameQ/server_listDoesnotexist.json');

// No servers should exist
$this->assertCount(0, $this->stub->getServers());
Expand Down
4 changes: 2 additions & 2 deletions tests/Protocol.php → tests/General/Protocol.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

namespace GameQ\Tests;
namespace GameQ\Tests\General;

/**
* Protocol test class
*
* @package GameQ\Tests
*/
class Protocol extends TestBase
class Protocol extends TestCase
{
/**
* Holds stub on setup
Expand Down
4 changes: 2 additions & 2 deletions tests/Server.php → tests/General/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

namespace GameQ\Tests;
namespace GameQ\Tests\General;

/**
* Server testing class
*
* @package GameQ\Tests
*/
class Server extends TestBase
class Server extends TestCase
{
/**
* Test for missing server type
Expand Down
29 changes: 29 additions & 0 deletions tests/General/TestCase.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php
/**
* This file is part of GameQ.
*
* GameQ is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* GameQ is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

namespace GameQ\Tests\General;

/**
* Class for testing the general structure of GameQ
*
* @package GameQ\Tests\Issues
*/
abstract class TestCase extends \GameQ\Tests\TestCase
{
//
}
Loading