Skip to content

Commit

Permalink
Symfony 5 and PhPUnit 9 update (#1)
Browse files Browse the repository at this point in the history
Update Symfony components to v5 and PHPUnit to v9
  • Loading branch information
ahaskioglu-valiton authored May 29, 2024
1 parent 270ab28 commit bf4fe76
Show file tree
Hide file tree
Showing 16 changed files with 77 additions and 108 deletions.
20 changes: 1 addition & 19 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,6 @@ name: CI
on: [push, pull_request]

jobs:
build-test-71:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- uses: php-actions/composer@v6
with:
version: 1
php_version: "7.1"

- name: PHPUnit Tests
uses: php-actions/phpunit@v3
with:
version: 7
php_version: "7.1"
configuration: phpunit.xml.dist
bootstrap: vendor/autoload.php
build-test-74:
runs-on: ubuntu-latest

Expand All @@ -35,7 +17,7 @@ jobs:
- name: PHPUnit Tests
uses: php-actions/phpunit@v3
with:
version: 7
version: 9
php_version: "7.4"
configuration: phpunit.xml.dist
bootstrap: vendor/autoload.php
10 changes: 4 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,16 @@
}
],
"require": {
"php": "^7.1",
"php": ">=7.3",
"naucon/utility": "~1.0",
"naucon/registry": "~1.0",
"doctrine/common": "^3.0.3"
},
"require-dev": {
"phpunit/phpunit": "^7.0",
"phpunit/phpunit": "^9.0",
"predis/predis": "^1.1",
"doctrine/orm": "~2.0",
"symfony/yaml": "^4.4",
"symfony/cache": "^4.4",
"symfony/http-foundation": "~2.8",
"doctrine/orm": "^2.0",
"symfony/http-foundation": "^4.0 || ^5.0",
"psr/cache": "~1.0",
"psr/simple-cache": "~1.0"
},
Expand Down
13 changes: 4 additions & 9 deletions tests/Identity/IdentityValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
*/
namespace Naucon\Storage\Tests\Identity;

use Naucon\Storage\Exception\InvalidArgumentException;
use Naucon\Storage\Identity\IdentityValidator;
use Naucon\Storage\Identity\IdentityValidatorInterface;
use PHPUnit\Framework\TestCase;
Expand Down Expand Up @@ -54,33 +55,27 @@ public function identifierProvider()
];
}

/**
* @expectedException \Naucon\Storage\Exception\InvalidArgumentException
*/
public function testValidateWithEmptyStringShouldThrowException()
{
$this->expectException(InvalidArgumentException::class);
$identifier = '';

$validator = new IdentityValidator();
$validator->validate($identifier);
}

/**
* @expectedException \Naucon\Storage\Exception\InvalidArgumentException
*/
public function testValidateWithNullShouldThrowException()
{
$this->expectException(InvalidArgumentException::class);
$identifier = null;

$validator = new IdentityValidator();
$validator->validate($identifier);
}

/**
* @expectedException \Naucon\Storage\Exception\InvalidArgumentException
*/
public function testValidateWithIllegalCharactersShouldThrowException()
{
$this->expectException(InvalidArgumentException::class);
$identifier = 'foo@';

$validator = new IdentityValidator();
Expand Down
6 changes: 3 additions & 3 deletions tests/Provider/ArrayStorageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@
class ArrayStorageTest extends TestCase
{
/**
* @var \Naucon\Storage\Tests\Model\Product
* @var Product
*/
protected $model1;

/**
* @var \Naucon\Storage\Tests\Model\Product
* @var Product
*/
protected $model2;



public function setUp()
public function setUp(): void
{
parent::setUp();

Expand Down
6 changes: 3 additions & 3 deletions tests/Provider/DoctrineStorageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
use Doctrine\Persistence\ObjectRepository;
use Naucon\Storage\Tests\Model\Product;
use Naucon\Storage\Provider\DoctrineStorage;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use PHPUnit_Framework_MockObject_MockObject;

class DoctrineStorageTest extends TestCase
{
Expand All @@ -29,13 +29,13 @@ class DoctrineStorageTest extends TestCase
protected $model2;

/**
* @var ObjectManager|PHPUnit_Framework_MockObject_MockObject
* @var ObjectManager|MockObject
*/
protected $objectManagerMock;



public function setUp()
public function setUp(): void
{
parent::setUp();

Expand Down
8 changes: 4 additions & 4 deletions tests/Provider/FileStorageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
class FileStorageTest extends TestCase
{
/**
* @var \Naucon\Storage\Tests\Model\Product
* @var Product
*/
protected $model1;

/**
* @var \Naucon\Storage\Tests\Model\Product
* @var Product
*/
protected $model2;

Expand All @@ -32,7 +32,7 @@ class FileStorageTest extends TestCase



public function setUp()
public function setUp(): void
{
parent::setUp();

Expand All @@ -50,7 +50,7 @@ public function setUp()
@mkdir($this->storageDir);
}

public function tearDown()
public function tearDown(): void
{
array_map('unlink', glob($this->storageDir . '/storage-model-*'));
if (is_dir($this->storageDir)) {
Expand Down
8 changes: 4 additions & 4 deletions tests/Provider/NativeSessionStorageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,18 @@
class NativeSessionStorageTest extends TestCase
{
/**
* @var \Naucon\Storage\Tests\Model\Product
* @var Product
*/
protected $model1;

/**
* @var \Naucon\Storage\Tests\Model\Product
* @var Product
*/
protected $model2;



public function setUp()
public function setUp(): void
{
parent::setUp();

Expand All @@ -47,7 +47,7 @@ public function setUp()
$this->model2->setDescription('Pear');
}

public function tearDown()
public function tearDown(): void
{
unset($_SESSION);

Expand Down
6 changes: 3 additions & 3 deletions tests/Provider/NullStorageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@
class NullStorageTest extends TestCase
{
/**
* @var \Naucon\Storage\Tests\Model\Product
* @var Product
*/
protected $model1;

/**
* @var \Naucon\Storage\Tests\Model\Product
* @var Product
*/
protected $model2;



public function setUp()
public function setUp(): void
{
parent::setUp();

Expand Down
16 changes: 8 additions & 8 deletions tests/Provider/PsrCacheStorageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
*/
namespace Naucon\Storage\Tests\Provider;

use Naucon\Storage\Exception\UnsupportedException;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use Psr\Cache\CacheItemInterface;
use Psr\Cache\CacheItemPoolInterface;
Expand All @@ -24,28 +26,28 @@
class PsrCacheStorageTest extends TestCase
{
/**
* @var CacheItemPoolInterface|\PHPUnit_Framework_MockObject_MockObject
* @var CacheItemPoolInterface|MockObject
*/
protected $cache;

/**
* @var CacheItemInterface|\PHPUnit_Framework_MockObject_MockObject
* @var CacheItemInterface|MockObject
*/
protected $cacheItem;

/**
* @var \Naucon\Storage\Tests\Model\Product
* @var Product
*/
protected $model1;

/**
* @var \Naucon\Storage\Tests\Model\Product
* @var Product
*/
protected $model2;



public function setUp()
public function setUp(): void
{
parent::setUp();

Expand Down Expand Up @@ -351,11 +353,9 @@ public function testHas()
$this->assertFalse($storage->has($badIdentifier));
}

/**
* @expectedException \Naucon\Storage\Exception\UnsupportedException
*/
public function testFindAll()
{
$this->expectException(UnsupportedException::class);
$cache = $this->cache;

$storage = new PsrCacheStorage($cache, Product::class);
Expand Down
14 changes: 7 additions & 7 deletions tests/Provider/PsrSimpleCacheStorageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@
*/
namespace Naucon\Storage\Tests\Provider;

use Naucon\Storage\Exception\UnsupportedException;
use Naucon\Storage\Provider\PsrSimpleCacheStorage;
use Naucon\Storage\Tests\Model\Product;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use Psr\SimpleCache\CacheInterface;

Expand All @@ -23,23 +25,23 @@
class PsrSimpleCacheStorageTest extends TestCase
{
/**
* @var CacheInterface|\PHPUnit_Framework_MockObject_MockObject
* @var CacheInterface|MockObject
*/
protected $cache;

/**
* @var \Naucon\Storage\Tests\Model\Product
* @var Product
*/
protected $model1;

/**
* @var \Naucon\Storage\Tests\Model\Product
* @var Product
*/
protected $model2;



public function setUp()
public function setUp(): void
{
parent::setUp();

Expand Down Expand Up @@ -269,11 +271,9 @@ public function testHas()
$this->assertFalse($storage->has($badIdentifier));
}

/**
* @expectedException \Naucon\Storage\Exception\UnsupportedException
*/
public function testFindAll()
{
$this->expectException(UnsupportedException::class);
$cache = $this->cache;

$storage = new PsrSimpleCacheStorage($cache, Product::class);
Expand Down
14 changes: 6 additions & 8 deletions tests/Provider/RedisStorageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
use Naucon\Storage\Exception\StorageException;
use Naucon\Storage\Provider\RedisStorage;
use Naucon\Storage\Tests\Model\Product;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use PHPUnit_Framework_MockObject_MockObject;
use Predis\Client;
use Predis\ClientException;
use Predis\Profile\ProfileInterface;
Expand All @@ -27,7 +27,7 @@
class RedisStorageTest extends TestCase
{
/**
* @var Client|PHPUnit_Framework_MockObject_MockObject
* @var Client|MockObject
*/
protected $client;

Expand All @@ -42,13 +42,13 @@ class RedisStorageTest extends TestCase
protected $model2;


public function setUp()
public function setUp(): void
{
parent::setUp();

$this->client = $this->getMockBuilder(Client::class)
->disableOriginalConstructor()
->setMethods(['get', 'mget', 'set', 'setex', 'del', 'exists', 'keys', 'scan', 'getProfile', 'flushdb'])
->addMethods(['get', 'mget', 'set', 'setex', 'del', 'exists', 'keys', 'scan', 'flushdb'])
->onlyMethods(['getProfile'])
->getMock();

$this->model1 = new Product();
Expand Down Expand Up @@ -447,9 +447,7 @@ public function testFindAllOnInaccessibleRedis()
$expectedKey = '52e848a7eeaa022db017f9b25087fc45:2';
$client = $this->client;

$profileInterface = $this->getMockBuilder(ProfileInterface::class)
->disableOriginalConstructor()
->getMock();
$profileInterface = $this->getMockBuilder(ProfileInterface::class)->getMock();

$profileInterface->expects($this->any())
->method('supportsCommand')
Expand Down
Loading

0 comments on commit bf4fe76

Please sign in to comment.