Skip to content

Commit

Permalink
Reworked test suite to run them via composer.
Browse files Browse the repository at this point in the history
  • Loading branch information
Geolim4 committed Jan 6, 2024
1 parent 4f430d1 commit 8e902fb
Show file tree
Hide file tree
Showing 60 changed files with 76 additions and 76 deletions.
12 changes: 3 additions & 9 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,13 @@ jobs:
- name: Install dependencies
run: ./bin/ci/scripts/install_dependencies.sh

- name: Run PHPCS
run: ./vendor/bin/phpcs lib/ --report=summary

- name: Run PHPMD
run: ./vendor/bin/phpmd lib/ ansi phpmd.xml

- name: Run PHPSTAN (lite)
run: ./vendor/bin/phpstan analyse lib/ -l 6 -c phpstan_lite.neon 2>&1
- name: Run QUALITY
run: composer run-script quality

- name: Run TESTS
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
GOOGLE_APPLICATION_CREDENTIALS: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }}
GOOGLE_CLOUD_PROJECT: ${{ secrets.GOOGLE_CLOUD_PROJECT }}
run: php -f ./bin/ci/run_tests.php
run: composer run-script tests
8 changes: 3 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ php:
- 8.0
- 8.1
- 8.2
# - nightly # nightly is currently too much unstable many bundled extension are not available...
- 8.3
jobs:
fast_finish: true
allow_failures:
Expand Down Expand Up @@ -60,7 +60,5 @@ install:
- "[[ $TRAVIS_PHP_VERSION != \"nightly\" ]] && ./bin/ci/scripts/install_dependencies.sh || ./bin/ci/scripts/install_dependencies_lite.sh"

script:
- ./vendor/bin/phpcs lib/ --report=summary
- ./vendor/bin/phpmd lib/ ansi phpmd.xml
- "[[ $TRAVIS_PHP_VERSION != \"nightly\" ]] && ./vendor/bin/phpstan analyse lib/ -l 6 -c phpstan.neon 2>&1 || ./vendor/bin/phpstan analyse lib/ -l 4 -c phpstan_lite.neon 2>&1"
- php -f ./bin/ci/run_tests.php
- composer run-script quality
- composer run-script tests
9 changes: 9 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,15 @@
"Phpfastcache\\Tests\\": "tests/lib/"
}
},
"scripts": {
"phpcs": "vendor/bin/phpcs lib/ --report=summary",
"phpmd": "vendor/bin/phpmd lib/ ansi phpmd.xml",
"phpstan": "vendor/bin/phpstan analyse lib/ -l 6 -c phpstan.neon",
"quality": ["@phpcs", "@phpmd", "@phpstan"],
"tests": [
"php tests/RunTests.php"
]
},
"support": {
"issues": "https://github.com/PHPSocialNetwork/phpfastcache/issues",
"wiki": "https://github.com/PHPSocialNetwork/phpfastcache/wiki",
Expand Down
4 changes: 2 additions & 2 deletions bin/ci/run_tests.php → tests/RunTests.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
* @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors
*/
declare(strict_types=1);
require __DIR__ . '/../../vendor/autoload.php';
require __DIR__ . '/../vendor/autoload.php';

define('PFC_TEST_DIR', \realpath(__DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'tests'));
define('PFC_TEST_DIR', \realpath(__DIR__));

$timestamp = microtime(true);
$climate = new League\CLImate\CLImate;
Expand Down
Binary file added tests/cache/cli/Sqlite/db1
Binary file not shown.
Binary file added tests/cache/cli/Sqlite/indexing
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
use Phpfastcache\Proxy\PhpfastcacheAbstractProxy;

chdir(__DIR__);
require_once __DIR__ . '/../vendor/autoload.php';
require_once __DIR__ . '/../../vendor/autoload.php';
$testHelper = new TestHelper('phpfastcacheAbstractProxy class');
$defaultDriver = (!empty($argv[1]) ? ucfirst($argv[1]) : 'Files');

Expand Down
3 changes: 1 addition & 2 deletions tests/Apcu.test.php → tests/cases/Apcu.test.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
use Phpfastcache\Tests\Helper\TestHelper;

chdir(__DIR__);
require_once __DIR__ . '/../vendor/autoload.php';
require_once __DIR__ . '/mock/Autoload.php';
require_once __DIR__ . '/../../vendor/autoload.php';
$testHelper = new TestHelper('Apcu test (CRUD)');
$pool = CacheManager::getInstance('Apcu');
$pool->clear();
Expand Down
2 changes: 1 addition & 1 deletion tests/Api.test.php → tests/cases/Api.test.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
use Phpfastcache\Tests\Helper\TestHelper;

chdir(__DIR__);
require_once __DIR__ . '/../vendor/autoload.php';
require_once __DIR__ . '/../../vendor/autoload.php';
$testHelper = new TestHelper('API class');

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/Arangodb.test.php → tests/cases/Arangodb.test.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
use Phpfastcache\Tests\Config\ConfigFactory;

chdir(__DIR__);
require_once __DIR__ . '/../vendor/autoload.php';
require_once __DIR__ . '/../../vendor/autoload.php';
$testHelper = new TestHelper('Arangodb driver');

try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
use Phpfastcache\Tests\Helper\TestHelper;

chdir(__DIR__);
require_once __DIR__ . '/../vendor/autoload.php';
require_once __DIR__ . '/mock/Autoload.php';
require_once __DIR__ . '/../../vendor/autoload.php';
require_once __DIR__ . '/../mock/Autoload.php';
$testHelper = new TestHelper('Atomic Operations');
$pool = CacheManager::getInstance('Memstatic');
$testHelper->printInfoText('Testing APPEND/PREPEND methods...');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
use Psr\Cache\CacheItemPoolInterface;

chdir(__DIR__);
require_once __DIR__ . '/../vendor/autoload.php';
require_once __DIR__ . '/../../vendor/autoload.php';
$testHelper = new TestHelper('[A|De]ttaching methods');
$defaultDriver = (!empty($argv[1]) ? ucfirst($argv[1]) : 'Files');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
use Phpfastcache\Tests\Helper\TestHelper;

chdir(__DIR__);
require_once __DIR__ . '/../vendor/autoload.php';
require_once __DIR__ . '/../../vendor/autoload.php';
$testHelper = new TestHelper('Clear single cache instance');
$defaultDriver = (!empty($argv[1]) ? \ucfirst($argv[1]) : 'Files');
$instanceId = str_shuffle(md5(\time() - \random_int(0, 86400)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
use Psr\Cache\CacheItemInterface;

chdir(__DIR__);
require_once __DIR__ . '/../vendor/autoload.php';
require_once __DIR__ . '/../../vendor/autoload.php';
$testHelper = new TestHelper('Cache Contract');
$defaultDriver = (!empty($argv[ 1 ]) ? ucfirst($argv[ 1 ]) : 'Files');
$cacheInstance = CacheManager::getInstance($defaultDriver);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
use Phpfastcache\Tests\Helper\TestHelper;

chdir(__DIR__);
require_once __DIR__ . '/../vendor/autoload.php';
require_once __DIR__ . '/../../vendor/autoload.php';
$testHelper = new TestHelper('New cache instance');
$defaultDriver = (!empty($argv[1]) ? ucfirst($argv[1]) : 'Files');
$instanceId = str_shuffle(md5(time() - mt_rand(0, 86400)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
use Phpfastcache\Tests\Helper\TestHelper;

chdir(__DIR__);
require_once __DIR__ . '/../vendor/autoload.php';
require_once __DIR__ . '/../../vendor/autoload.php';
$testHelper = new TestHelper('Cache Item Atomic Methods');
$defaultDriver = (!empty($argv[1]) ? ucfirst($argv[1]) : 'Files');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
use Psr\Cache\CacheItemPoolInterface;

chdir(__DIR__);
require_once __DIR__ . '/../vendor/autoload.php';
require_once __DIR__ . '/../../vendor/autoload.php';
$testHelper = new TestHelper('Cache option: itemDetailedDate');
$defaultDriver = (!empty($argv[ 1 ]) ? ucfirst($argv[ 1 ]) : 'Files');
$cacheInstance = CacheManager::getInstance($defaultDriver, new ConfigurationOption([
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
use Phpfastcache\Tests\Helper\TestHelper;

chdir(__DIR__);
require_once __DIR__ . '/../vendor/autoload.php';
require_once __DIR__ . '/../../vendor/autoload.php';
$testHelper = new TestHelper('Cache Slams Protection');
$defaultDriver = (!empty($argv[ 1 ]) ? ucfirst($argv[ 1 ]) : 'Files');
$driverInstance = CacheManager::getInstance($defaultDriver, new IOConfigurationOption([
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
use Phpfastcache\Tests\Helper\TestHelper;

chdir(__DIR__);
require_once __DIR__ . '/../vendor/autoload.php';
require_once __DIR__ . '/../../vendor/autoload.php';
$testHelper = new TestHelper('Full Replication Cluster');

$clusterAggregator = new ClusterAggregator('test_20');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
use Phpfastcache\Tests\Helper\TestHelper;

chdir(__DIR__);
require_once __DIR__ . '/../vendor/autoload.php';
require_once __DIR__ . '/mock/Autoload.php';
require_once __DIR__ . '/../../vendor/autoload.php';
require_once __DIR__ . '/../mock/Autoload.php';
$testHelper = new TestHelper('Master/Slave Replication Cluster');

CacheManager::addCustomDriver('Failfiles', FailFilesDriver::class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
use Phpfastcache\Tests\Helper\TestHelper;

chdir(__DIR__);
require_once __DIR__ . '/../vendor/autoload.php';
require_once __DIR__ . '/mock/Autoload.php';
require_once __DIR__ . '/../../vendor/autoload.php';
require_once __DIR__ . '/../mock/Autoload.php';
$testHelper = new TestHelper('Master/Slave Replication Cluster');

CacheManager::clearInstances();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
use Phpfastcache\Tests\Helper\TestHelper;

chdir(__DIR__);
require_once __DIR__ . '/../vendor/autoload.php';
require_once __DIR__ . '/../../vendor/autoload.php';
$testHelper = new TestHelper('Semi Replication Cluster');

$clusterAggregator = new ClusterAggregator('test_20');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
use Phpfastcache\Drivers\Files\Config as FilesConfig;

chdir(__DIR__);
require_once __DIR__ . '/../vendor/autoload.php';
require_once __DIR__ . '/../../vendor/autoload.php';
$testHelper = new TestHelper('Configuration validator');


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
use Phpfastcache\Tests\Helper\TestHelper;

chdir(__DIR__);
require_once __DIR__ . '/../vendor/autoload.php';
require_once __DIR__ . '/mock/Autoload.php';
require_once __DIR__ . '/../../vendor/autoload.php';
require_once __DIR__ . '/../mock/Autoload.php';
$testHelper = new TestHelper('Core driver override');

if (!class_exists(Phpfastcache\DriverTest\Files2\Item::class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
use Phpfastcache\Tests\Helper\TestHelper;

chdir(__DIR__);
require_once __DIR__ . '/../vendor/autoload.php';
require_once __DIR__ . '/../../vendor/autoload.php';
$testHelper = new TestHelper('Couchbasev3 driver');

$config = new CouchbaseConfig();
Expand Down
2 changes: 1 addition & 1 deletion tests/Couchdb.test.php → tests/cases/Couchdb.test.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
use Phpfastcache\Tests\Config\ConfigFactory;

chdir(__DIR__);
require_once __DIR__ . '/../vendor/autoload.php';
require_once __DIR__ . '/../../vendor/autoload.php';
$testHelper = new TestHelper('Couchdb driver');

$config = new CouchdbConfig();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
use Phpfastcache\Tests\Helper\TestHelper;

chdir(__DIR__);
require_once __DIR__ . '/../vendor/autoload.php';
require_once __DIR__ . '/../../vendor/autoload.php';
$testHelper = new TestHelper('Custom filename function');
$driverInstance = CacheManager::getInstance(
'Files',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
use Phpfastcache\Tests\Helper\TestHelper;

chdir(__DIR__);
require_once __DIR__ . '/../vendor/autoload.php';
require_once __DIR__ . '/../../vendor/autoload.php';
$testHelper = new TestHelper('Custom key hash function');
$driverInstance = CacheManager::getInstance(
'sqlite',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
use Phpfastcache\Tests\Helper\TestHelper;

chdir(__DIR__);
require_once __DIR__ . '/../vendor/autoload.php';
require_once __DIR__ . '/mock/Autoload.php';
require_once __DIR__ . '/../../vendor/autoload.php';
require_once __DIR__ . '/../mock/Autoload.php';
$testHelper = new TestHelper('Custom driver');

if (!class_exists(Phpfastcache\Drivers\Fakefiles\Item::class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
use Phpfastcache\Tests\Helper\TestHelper;

chdir(__DIR__);
require_once __DIR__ . '/../vendor/autoload.php';
require_once __DIR__ . '/../../vendor/autoload.php';
$testHelper = new TestHelper('Custom key hash function');

function myAwesomeHashFunction($string)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
use Phpfastcache\Tests\Helper\TestHelper;

chdir(__DIR__);
require_once __DIR__ . '/../vendor/autoload.php';
require_once __DIR__ . '/../../vendor/autoload.php';
$testHelper = new TestHelper('Testing disabling static item caching');
$defaultDriver = (!empty($argv[ 1 ]) ? ucfirst($argv[ 1 ]) : 'Files');
$driverInstance = CacheManager::getInstance($defaultDriver, new ConfigurationOption([
Expand Down
2 changes: 1 addition & 1 deletion tests/DriverIO.test.php → tests/cases/DriverIO.test.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
use Phpfastcache\Tests\Helper\TestHelper;

chdir(__DIR__);
require_once __DIR__ . '/../vendor/autoload.php';
require_once __DIR__ . '/../../vendor/autoload.php';
$testHelper = new TestHelper('Driver list resolver');

$cache = CacheManager::getInstance('Redis');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
use Phpfastcache\Tests\Helper\TestHelper;

chdir(__DIR__);
require_once __DIR__ . '/../vendor/autoload.php';
require_once __DIR__ . '/../../vendor/autoload.php';
$testHelper = new TestHelper('Driver list resolver');

$subClasses = [
Expand Down
2 changes: 1 addition & 1 deletion tests/Dynamodb.test.php → tests/cases/Dynamodb.test.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
use Phpfastcache\Tests\Helper\TestHelper;

chdir(__DIR__);
require_once __DIR__ . '/../vendor/autoload.php';
require_once __DIR__ . '/../../vendor/autoload.php';
$testHelper = new TestHelper('Amazon Dynamodb driver');

$config = new DynamodbConfig();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
use Phpfastcache\Tests\Helper\TestHelper;

chdir(__DIR__);
require_once __DIR__ . '/../vendor/autoload.php';
require_once __DIR__ . '/../../vendor/autoload.php';
$testHelper = new TestHelper('EventManager (Unscoped)');
$defaultDriver = (!empty($argv[1]) ? ucfirst($argv[1]) : 'Files');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
use Phpfastcache\Tests\Helper\TestHelper;

chdir(__DIR__);
require_once __DIR__ . '/../vendor/autoload.php';
require_once __DIR__ . '/../../vendor/autoload.php';
$testHelper = new TestHelper('EventManager (Scoped)');
$defaultDriver = (!empty($argv[1]) ? ucfirst($argv[1]) : 'Files');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
use Phpfastcache\Tests\Helper\TestHelper;

chdir(__DIR__);
require_once __DIR__ . '/../vendor/autoload.php';
require_once __DIR__ . '/../../vendor/autoload.php';
$testHelper = new TestHelper('Google Firestore driver');

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
use Phpfastcache\EventManager;

chdir(__DIR__);
require_once __DIR__ . '/../vendor/autoload.php';
require_once __DIR__ . '/../../vendor/autoload.php';

$testHelper = new TestHelper('Testing getAllItems() method');

Expand Down
2 changes: 1 addition & 1 deletion tests/ItemTags.test.php → tests/cases/ItemTags.test.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
use Phpfastcache\Tests\Helper\TestHelper;

chdir(__DIR__);
require_once __DIR__ . '/../vendor/autoload.php';
require_once __DIR__ . '/../../vendor/autoload.php';
$testHelper = new TestHelper('Items tags features');
$defaultDriver = (!empty($argv[ 1 ]) ? ucfirst($argv[ 1 ]) : 'Redis');
$driverInstance = CacheManager::getInstance($defaultDriver);
Expand Down
2 changes: 1 addition & 1 deletion tests/Memcache.test.php → tests/cases/Memcache.test.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
use Phpfastcache\Tests\Helper\TestHelper;

chdir(__DIR__);
require_once __DIR__ . '/../vendor/autoload.php';
require_once __DIR__ . '/../../vendor/autoload.php';
$testHelper = new TestHelper('Memcache driver');


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
use Phpfastcache\Tests\Helper\TestHelper;

chdir(__DIR__);
require_once __DIR__ . '/../vendor/autoload.php';
require_once __DIR__ . '/../../vendor/autoload.php';
$testHelper = new TestHelper('Memcached');

$cacheInstanceDefSyntax = CacheManager::getInstance('Memcached');
Expand Down
Loading

0 comments on commit 8e902fb

Please sign in to comment.