Skip to content

Commit

Permalink
Merge fcfac07 into 6b451d9
Browse files Browse the repository at this point in the history
  • Loading branch information
DerManoMann committed Feb 18, 2021
2 parents 6b451d9 + fcfac07 commit e9dbff5
Show file tree
Hide file tree
Showing 25 changed files with 151 additions and 114 deletions.
81 changes: 81 additions & 0 deletions .github/workflows/build.yml
@@ -0,0 +1,81 @@
name: build

on:
push:
pull_request_target:
pull_request:

jobs:
php-cs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
name: Checkout repository

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.0'

- uses: ramsey/composer-install@v1
with:
dependency-versions: 'highest'

- name: Static Code Analysis
run: composer lint

test:
runs-on: ${{ matrix.operating-system }}
needs:
- php-cs
strategy:
fail-fast: true
matrix:
operating-system: [ ubuntu-latest ]
php: [ '7.2', '7.3', '7.4', '8.0' ]
redis: [ '5' ]
dependencies: [ 'lowest', 'highest' ]

name: PHP ${{ matrix.php }} on ${{ matrix.operating-system }} with ${{ matrix.dependencies }} dependencies

steps:
- uses: actions/checkout@v2
name: Checkout repository

- name: Cache dependencies
uses: actions/cache@v2
with:
path: ~/.composer/cache/files
key: dependencies-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }}

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: pdo_sqlite, apc, apcu
ini-values: apc.enabled=1, apc.enable_cli=1
coverage: pcov

- name: Start Redis
uses: supercharge/redis-github-action@1.1.0
with:
redis-version: ${{ matrix.redis }}

- name: Composer install
uses: ramsey/composer-install@v1
with:
dependency-versions: ${{ matrix.dependencies }}
composer-options: ${{ matrix.composer-options }}

- name: PHPUnit + Code coverage
run: |
mkdir -p build/logs
vendor/bin/phpunit --coverage-text --coverage-clover build/logs/clover.xml
- name: Code coverage upload to Coveralls
if: matrix.php == '8.0' && matrix.dependencies == 'highest'
env:
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
composer require php-coveralls/php-coveralls
vendor/bin/php-coveralls -v --coverage_clover=build/logs/clover.xml
6 changes: 5 additions & 1 deletion .gitignore
@@ -1,6 +1,10 @@
.idea/
.settings/
build/
vendor/
.buildpath
.phpunit.result.cache
.php_cs
.php_cs.cache
.project
composer.lock
phpunit.ini
4 changes: 3 additions & 1 deletion .php_cs.dist
@@ -1,6 +1,8 @@
<?php

$finder = PhpCsFixer\Finder::create()
->path('src')->name('*.php')
->path('tests')->name('*.php')
->in(__DIR__)
;

Expand Down Expand Up @@ -57,4 +59,4 @@ return PhpCsFixer\Config::create()
'phpdoc_no_alias_tag' => true,
])
->setFinder($finder)
;
;
43 changes: 0 additions & 43 deletions .travis.yml

This file was deleted.

5 changes: 0 additions & 5 deletions .travis_php.ini

This file was deleted.

2 changes: 1 addition & 1 deletion Readme.md
@@ -1,7 +1,7 @@
ACache, a flexible PHP cache library
====================================

[![Build Status](https://travis-ci.org/DerManoMann/acache.png)](https://travis-ci.org/DerManoMann/acache)
[![Build Status](https://github.com/DerManoMann/acache/workflows/build/badge.svg)](https://github.com/DerManoMann/acache/actions?query=workflow:build)
[![Coverage Status](https://coveralls.io/repos/DerManoMann/acache/badge.png)](https://coveralls.io/r/DerManoMann/acache)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

Expand Down
23 changes: 13 additions & 10 deletions composer.json
Expand Up @@ -24,24 +24,27 @@
"sort-packages": true
},
"scripts": {
"fix-cs": [
"vendor/bin/php-cs-fixer fix src",
"vendor/bin/php-cs-fixer fix tests"
"cs": "php-cs-fixer fix --allow-risky=yes",
"lint": "@cs --dry-run",
"test": [
"phpunit",
"@lint"
]
},
"require": {
"php": ">=7.1",
"php": ">=7.2",
"ext-json": "*",
"psr/cache": "^1.0",
"psr/log": "^1.0"
},
"require-dev": {
"cache/integration-tests": "^0.16",
"ext-memcached": "*",
"ext-redis": "*",
"cache/cache": "^1.0",
"php-coveralls/php-coveralls": "~2.1",
"phpunit/php-code-coverage": "^6.1|^7.0.5",
"phpunit/phpunit": "^7.0",
"friendsofphp/php-cs-fixer":"^2.13",
"doctrine/cache": "^1.3"
"cache/integration-tests": "~0.17",
"doctrine/cache": "^1.3",
"friendsofphp/php-cs-fixer": "^2.17",
"phpunit/phpunit": ">=8.0"
},
"autoload": {
"psr-4": {
Expand Down
33 changes: 11 additions & 22 deletions phpunit.xml.dist
@@ -1,24 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>

<phpunit backupGlobals="false"
backupStaticAttributes="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
bootstrap="./tests/bootstrap.php"
>
<testsuites>
<testsuite name="ACache Test Suite">
<directory suffix="Test.php">./tests/Radebatz/ACache/Tests/</directory>
</testsuite>
</testsuites>

<filter>
<whitelist>
<directory>src</directory>
</whitelist>
</filter>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" backupStaticAttributes="false" colors="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false" stopOnFailure="false" bootstrap="./tests/bootstrap.php" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage>
<include>
<directory>src</directory>
</include>
</coverage>
<testsuites>
<testsuite name="ACache Test Suite">
<directory suffix="Test.php">./tests/Radebatz/ACache/Tests/</directory>
</testsuite>
</testsuites>
</phpunit>
6 changes: 3 additions & 3 deletions src/Radebatz/ACache/ApcCache.php
Expand Up @@ -114,9 +114,9 @@ public function getStats()
// @TODO - Temporary fix @see https://github.com/krakjoe/apcu/pull/42 AND hhvm compat
if (PHP_VERSION_ID >= 50500) {
// apcu + hhvm
$cacheInfo['num_hits'] = isset($cacheInfo['nhits']) ? $cacheInfo['num_hits'] : isset($cacheInfo['num_hits']) ? $cacheInfo['num_hits'] : 0;
$cacheInfo['num_misses'] = isset($cacheInfo['nmisses']) ? $cacheInfo['num_misses'] : isset($cacheInfo['num_misses']) ? $cacheInfo['num_misses'] : 0;
$cacheInfo['start_time'] = isset($cacheInfo['stime']) ? $cacheInfo['start_time'] : isset($cacheInfo['start_time']) ? $cacheInfo['start_time'] : 0;
$cacheInfo['num_hits'] = isset($cacheInfo['nhits']) ? $cacheInfo['num_hits'] : (isset($cacheInfo['num_hits']) ? $cacheInfo['num_hits'] : 0);
$cacheInfo['num_misses'] = isset($cacheInfo['nmisses']) ? $cacheInfo['num_misses'] : (isset($cacheInfo['num_misses']) ? $cacheInfo['num_misses'] : 0);
$cacheInfo['start_time'] = isset($cacheInfo['stime']) ? $cacheInfo['start_time'] : (isset($cacheInfo['start_time']) ? $cacheInfo['start_time'] : 0);

// hhvm
$cacheInfo['mem_size'] = isset($cacheInfo['mem_size']) ? $cacheInfo['mem_size'] : 0;
Expand Down
4 changes: 2 additions & 2 deletions src/Radebatz/ACache/Decorators/Psr/CacheItem.php
Expand Up @@ -20,9 +20,9 @@ class CacheItem implements CacheItemInterface
{
protected $key;
protected $value;
/** @var $cache CacheItemPool */
/** @var CacheItemPool */
protected $cacheItemPool;
/** @var $expiresAt \DateTimeInterface */
/** @var \DateTimeInterface */
protected $expiresAt;

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Radebatz/ACache/Decorators/Psr/CacheItemPool.php
Expand Up @@ -22,7 +22,7 @@ class CacheItemPool implements CacheItemPoolInterface
{
const BAD_KEY_CHARS = '{}()/\@:';

/** @var $cache CacheInterface */
/** @var CacheInterface */
protected $cache;
protected $deferred;

Expand Down
2 changes: 1 addition & 1 deletion tests/Radebatz/ACache/Tests/ApcCacheTest.php
Expand Up @@ -21,7 +21,7 @@ class ApcCacheTest extends NamespaceCacheTest
/**
* {@inheritdoc}
*/
protected function setUp()
protected function setUp(): void
{
$cache = new ApcCache();
if (!$cache->available()) {
Expand Down
2 changes: 1 addition & 1 deletion tests/Radebatz/ACache/Tests/ApcGCTest.php
Expand Up @@ -31,7 +31,7 @@ protected function hasApc()
/**
* {@inheritdoc}
*/
protected function setUp()
protected function setUp(): void
{
if (!$this->hasApc()) {
$this->markTestSkipped('Skipping Apc');
Expand Down
2 changes: 1 addition & 1 deletion tests/Radebatz/ACache/Tests/CacheTest.php
Expand Up @@ -51,7 +51,7 @@ protected function getProperty($obj, $name)
return $property->getValue($obj);
}

return;
return null;
}

/**
Expand Down
Expand Up @@ -31,7 +31,7 @@ protected function hasDoctrineCache()
/**
* {@inheritdoc}
*/
protected function setUp()
protected function setUp(): void
{
if (!$this->hasDoctrineCache()) {
$this->markTestSkipped('Skipping DoctrineCache');
Expand Down
Expand Up @@ -14,6 +14,7 @@
use PHPUnit\Framework\TestCase;
use Radebatz\ACache\ArrayCache;
use Radebatz\ACache\Decorators\Psr\CacheItemPool;
use Radebatz\ACache\Decorators\Psr\InvalidArgumentException;

/**
* Psr CacheItemPool tests.
Expand Down Expand Up @@ -171,11 +172,11 @@ public function testPoolCommit()

/**
* Test invalid key.
*
* @expectedException Radebatz\ACache\Decorators\Psr\InvalidArgumentException
*/
public function testInvalidKey()
{
$this->expectException(InvalidArgumentException::class);

$cachePool = $this->getCachePool();
$cachePool->getItem('(foo');
}
Expand Down
9 changes: 5 additions & 4 deletions tests/Radebatz/ACache/Tests/Decorators/Psr/CacheItemTest.php
Expand Up @@ -15,6 +15,7 @@
use Radebatz\ACache\ArrayCache;
use Radebatz\ACache\Decorators\Psr\CacheItem;
use Radebatz\ACache\Decorators\Psr\CacheItemPool;
use Radebatz\ACache\Decorators\Psr\InvalidArgumentException;

/**
* Psr CacheItem tests.
Expand Down Expand Up @@ -61,22 +62,22 @@ public function testHit()

/**
* Test invalid expiresAt.
*
* @expectedException Radebatz\ACache\Decorators\Psr\InvalidArgumentException
*/
public function testInvalidExpiresAt()
{
$this->expectException(InvalidArgumentException::class);

$cacheItem = $this->getCacheItem('ping', 'pong');
$cacheItem->expiresAt('yo');
}

/**
* Test invalid key.
*
* @expectedException Radebatz\ACache\Decorators\Psr\InvalidArgumentException
*/
public function testInvalidKey()
{
$this->expectException(InvalidArgumentException::class);

$this->getCacheItem('{ping', 'pong');
}

Expand Down

0 comments on commit e9dbff5

Please sign in to comment.