Skip to content
Merged
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
4 changes: 2 additions & 2 deletions .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Configure PHP environment
uses: shivammathur/setup-php@v2
with:
php-version: '8.0'
extensions: mbstring, intl
coverage: none
- uses: ramsey/composer-install@v2
- uses: ramsey/composer-install@v3
with:
composer-options: "--ignore-platform-reqs --optimize-autoloader"
- name: Run PHPStan static analysis
Expand Down
19 changes: 3 additions & 16 deletions .github/workflows/tests-php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,34 +15,21 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout the repository
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 1000
submodules: recursive
# ------------------------------------------------------------------------------
# Checkout slic
# ------------------------------------------------------------------------------
- name: Checkout slic
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
repository: stellarwp/slic
ref: main
path: slic
fetch-depth: 1
# ------------------------------------------------------------------------------
# Prepare our composer cache directory
# ------------------------------------------------------------------------------
- name: Get Composer Cache Directory
id: get-composer-cache-dir
run: |
echo "::set-output name=dir::$(composer config cache-files-dir)"
- uses: actions/cache@v2
id: composer-cache
with:
path: ${{ steps.get-composer-cache-dir.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-

# ------------------------------------------------------------------------------
# Initialize slic
# ------------------------------------------------------------------------------
Expand Down
15 changes: 13 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"autoload-dev": {
"psr-4": {
"StellarWP\\Memoize\\Tests\\": "tests/",
"StellarWP\\Memoize\\Tests\\Unit\\": "tests/unit/",
"StellarWP\\Memoize\\Tests\\Helper\\": "tests/_support/Helper/",
"StellarWP\\Memoize\\Tests\\Support\\": "tests/_support/Support/"
}
Expand All @@ -35,7 +36,9 @@
"stellarwp/coding-standards": "^2.0",
"symfony/event-dispatcher-contracts": "^2.5.1",
"symfony/string": "^5.4",
"szepeviktor/phpstan-wordpress": "^1.1"
"szepeviktor/phpstan-wordpress": "^1.1",
"phpstan/phpstan-phpunit": "^1.4",
"phpstan/extension-installer": "*"
},
"scripts": {
"lint": "vendor/bin/phpcs",
Expand All @@ -59,7 +62,15 @@
},
"config": {
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
"dealerdirect/phpcodesniffer-composer-installer": true,
"phpstan/extension-installer": true
}
},
"extra": {
"phpstan": {
"includes": [
"extension.neon"
]
}
}
}
2 changes: 0 additions & 2 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
includes:
# @see https://github.com/phpstan/phpstan-src/blob/master/conf/bleedingEdge.neon
- phar://phpstan.phar/conf/bleedingEdge.neon
# Include this extension
- vendor/szepeviktor/phpstan-wordpress/extension.neon

parameters:
parallel:
Expand Down
9 changes: 8 additions & 1 deletion tests/_support/Helper/MemoizeTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@

namespace StellarWP\Memoize\Tests\Helper;

class MemoizeTestCase extends \Codeception\TestCase\WPTestCase {
use lucatume\WPBrowser\TestCase\WPTestCase;

/**
* @mixin \Codeception\Test\Unit
* @mixin \PHPUnit\Framework\TestCase
* @mixin \Codeception\PHPUnit\TestCase
*/
class MemoizeTestCase extends WPTestCase {
protected $backupGlobals = false;
}

14 changes: 9 additions & 5 deletions tests/unit/ClosureTest.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
<?php
namespace StellarWP\Memoize;

use StellarWP\Memoize\Tests\Helper\MemoizeTestCase;
declare(strict_types=1);

namespace StellarWP\Memoize\Tests\Unit;

use StellarWP\Memoize\Contracts\MemoizerInterface;
use StellarWP\Memoize\Drivers\MemoryDriver;
use StellarWP\Memoize\Memoizer;
use StellarWP\Memoize\Tests\Helper\MemoizeTestCase;

final class ClosureTest extends MemoizeTestCase
{
Expand All @@ -14,7 +18,7 @@ public function _setUp(): void
$this->memoizer = new Memoizer(new MemoryDriver());
}

public function testResolvesClosures()
public function testResolvesClosures(): void
{
$this->memoizer->set('foo', function () {
return 'bar';
Expand All @@ -27,7 +31,7 @@ public function testResolvesClosures()
$this->assertEquals('bar', $this->memoizer->get('foo.baz'));
}

public function testResolvesClosuresRecursively()
public function testResolvesClosuresRecursively(): void
{
$this->memoizer->set('one', function () {
return 'bar';
Expand All @@ -50,7 +54,7 @@ public function testResolvesClosuresRecursively()
$this->assertEquals('bar', $cache['three']['baz']['whee']);
}

public function testResolvesClosuresRecursivelyWhenGrabbingInTheMiddle()
public function testResolvesClosuresRecursivelyWhenGrabbingInTheMiddle(): void
{
$this->memoizer->set('bar.baz.whee', function () {
return 'bar';
Expand Down
20 changes: 12 additions & 8 deletions tests/unit/MemoizeTest.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
<?php
namespace StellarWP\Memoize;

use StellarWP\Memoize\Tests\Helper\MemoizeTestCase;
declare(strict_types=1);

namespace StellarWP\Memoize\Tests\Unit;

use StellarWP\Memoize\Contracts\MemoizerInterface;
use StellarWP\Memoize\Drivers\MemoryDriver;
use StellarWP\Memoize\Memoizer;
use StellarWP\Memoize\Tests\Helper\MemoizeTestCase;

final class MemoizeTest extends MemoizeTestCase
{
Expand All @@ -14,19 +18,19 @@ public function _setUp(): void
$this->memoizer = new Memoizer(new MemoryDriver());
}

public function testSetsSimpleValue()
public function testSetsSimpleValue(): void
{
$this->memoizer->set('foo', 'bar');
$this->assertEquals('bar', $this->memoizer->get('foo'));
}

public function testSetsDeepValue()
public function testSetsDeepValue(): void
{
$this->memoizer->set('foo.bar.bork.blarg.moo', 'baz');
$this->assertEquals('baz', $this->memoizer->get('foo.bar.bork.blarg.moo'));
}

public function testForgetsEverything()
public function testForgetsEverything(): void
{
$this->memoizer->set('foo.bar.bork.blarg.moo', 'baz');
$this->memoizer->forget();
Expand All @@ -37,7 +41,7 @@ public function testForgetsEverything()
$this->assertFalse($this->memoizer->has('foo'));
}

public function testForgetsLeaves()
public function testForgetsLeaves(): void
{
$this->memoizer->set('foo.bar.bork.blarg.moo', 'baz');
$this->memoizer->set('foo.bar.bork.blarg.oink', 'lol');
Expand All @@ -46,7 +50,7 @@ public function testForgetsLeaves()
$this->assertTrue($this->memoizer->has('foo.bar.bork.blarg.oink'));
}

public function testForgetsBranches()
public function testForgetsBranches(): void
{
$this->memoizer->set('foo.bar.bork.blarg.moo', 'baz');
$this->memoizer->set('foo.bar.bork.blarg.oink', 'lol');
Expand All @@ -55,7 +59,7 @@ public function testForgetsBranches()
$this->assertTrue($this->memoizer->has('foo.bar'));
}

public function testForgetsSimpleValues()
public function testForgetsSimpleValues(): void
{
$this->memoizer->set('foo', 'baz');
$this->memoizer->set('bork', 'lol');
Expand Down
Loading