Skip to content

Commit

Permalink
update dev dependencies, fix formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
tedivm committed Dec 8, 2017
1 parent f20a99b commit 5e324b4
Show file tree
Hide file tree
Showing 17 changed files with 104 additions and 66 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -6,3 +6,5 @@
/vendor
/report
/build

.php_cs.cache
11 changes: 0 additions & 11 deletions .php_cs

This file was deleted.

6 changes: 3 additions & 3 deletions composer.json
Expand Up @@ -25,12 +25,12 @@
}
],
"require": {
"php": "^5.4|^7.0",
"php": "^7.0",
"psr/cache": "~1.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^1.9",
"phpunit/phpunit": "4.8.*",
"friendsofphp/php-cs-fixer": "^2.8",
"phpunit/phpunit": "^6",
"satooshi/php-coveralls": "1.0.*"
},
"autoload": {
Expand Down
13 changes: 9 additions & 4 deletions src/Stash/Item.php
Expand Up @@ -249,7 +249,8 @@ public function get()
$this->data = $this->executeGet(
$this->invalidationMethod,
$this->invalidationArg1,
$this->invalidationArg2);
$this->invalidationArg2
);
}

if (false === $this->isHit) {
Expand Down Expand Up @@ -569,9 +570,13 @@ protected function logException($message, $exception)
return false;
}

$this->logger->critical($message,
array('exception' => $exception,
'key' => $this->keyString));
$this->logger->critical(
$message,
array(
'exception' => $exception,
'key' => $this->keyString
)
);

return true;
}
Expand Down
6 changes: 4 additions & 2 deletions src/Stash/Pool.php
Expand Up @@ -321,8 +321,10 @@ protected function logException($message, $exception)
return false;
}

$this->logger->critical($message,
array('exception' => $exception));
$this->logger->critical(
$message,
array('exception' => $exception)
);

return true;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Stash/Test/AbstractItemTest.php
Expand Up @@ -23,7 +23,7 @@
*
* @todo find out why this has to be abstract to work (see https://github.com/tedivm/Stash/pull/10)
*/
abstract class AbstractItemTest extends \PHPUnit_Framework_TestCase
abstract class AbstractItemTest extends \PHPUnit\Framework\TestCase
{
protected $data = array('string' => 'Hello world!',
'complexString' => "\t\t\t\tHello\r\n\rWorld!",
Expand Down
18 changes: 12 additions & 6 deletions tests/Stash/Test/AbstractPoolTest.php
Expand Up @@ -21,7 +21,7 @@
* @package Stash
* @author Robert Hafner <tedivm@tedivm.com>
*/
class AbstractPoolTest extends \PHPUnit_Framework_TestCase
class AbstractPoolTest extends \PHPUnit\Framework\TestCase
{
protected $data = array(array('test', 'test'));
protected $multiData = array('key' => 'value',
Expand All @@ -47,7 +47,7 @@ public function testSetItemDriver()

public function testSetItemClass()
{
$mockItem = $this->getMock('Stash\Interfaces\ItemInterface');
$mockItem = $this->createMock('Stash\Interfaces\ItemInterface');
$mockClassName = get_class($mockItem);
$pool = $this->getTestPool();

Expand Down Expand Up @@ -316,8 +316,11 @@ public function testLoggerClear()
// triggerlogging
$pool->clear();

$this->assertInstanceOf('Stash\Test\Exception\TestException',
$logger->lastContext['exception'], 'Logger was passed exception in event context.');
$this->assertInstanceOf(
'Stash\Test\Exception\TestException',
$logger->lastContext['exception'],
'Logger was passed exception in event context.'
);

$this->assertTrue(strlen($logger->lastMessage) > 0, 'Logger message set after "get" exception.');
$this->assertEquals('critical', $logger->lastLevel, 'Exceptions logged as critical.');
Expand All @@ -336,8 +339,11 @@ public function testLoggerPurge()
// triggerlogging
$pool->purge();

$this->assertInstanceOf('Stash\Test\Exception\TestException',
$logger->lastContext['exception'], 'Logger was passed exception in event context.');
$this->assertInstanceOf(
'Stash\Test\Exception\TestException',
$logger->lastContext['exception'],
'Logger was passed exception in event context.'
);
$this->assertTrue(strlen($logger->lastMessage) > 0, 'Logger message set after "set" exception.');
$this->assertEquals('critical', $logger->lastLevel, 'Exceptions logged as critical.');
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Stash/Test/CacheExceptionTest.php
Expand Up @@ -20,7 +20,7 @@
* @package Stash
* @author Robert Hafner <tedivm@tedivm.com>
*/
class CacheExceptionTest extends \PHPUnit_Framework_TestCase
class CacheExceptionTest extends \PHPUnit\Framework\TestCase
{
public function testSet()
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Stash/Test/Driver/AbstractDriverTest.php
Expand Up @@ -17,7 +17,7 @@
* @package Stash
* @author Robert Hafner <tedivm@tedivm.com>
*/
abstract class AbstractDriverTest extends \PHPUnit_Framework_TestCase
abstract class AbstractDriverTest extends \PHPUnit\Framework\TestCase
{
protected $data = array('string' => 'Hello world!',
'complexString' => "\t\tHello\r\n\r\'\'World!\"\'\\",
Expand Down
2 changes: 1 addition & 1 deletion tests/Stash/Test/Driver/BlackHoleTest.php
Expand Up @@ -16,7 +16,7 @@
/**
* @author Benjamin Zikarsky <benjamin.zikarsky@perbility.de>
*/
class BlackHoleTest extends \PHPUnit_Framework_TestCase
class BlackHoleTest extends \PHPUnit\Framework\TestCase
{
/**
* @var Stash\Driver\BlackHole
Expand Down
2 changes: 1 addition & 1 deletion tests/Stash/Test/Driver/MemcacheAnyTest.php
Expand Up @@ -19,7 +19,7 @@
* @package Stash
* @author Robert Hafner <tedivm@tedivm.com>
*/
class MemcacheAnyTest extends \PHPUnit_Framework_TestCase
class MemcacheAnyTest extends \PHPUnit\Framework\TestCase
{
protected $driverClass = 'Stash\Driver\Memcache';

Expand Down
2 changes: 1 addition & 1 deletion tests/Stash/Test/Driver/SqliteAnyTest.php
Expand Up @@ -21,7 +21,7 @@
* @package Stash
* @author Robert Hafner <tedivm@tedivm.com>
*/
class SqliteAnyTest extends \PHPUnit_Framework_TestCase
class SqliteAnyTest extends \PHPUnit\Framework\TestCase
{
protected $driverClass = 'Stash\Driver\Sqlite';

Expand Down
2 changes: 1 addition & 1 deletion tests/Stash/Test/Driver/UnavailableDriverTest.php
Expand Up @@ -17,7 +17,7 @@
* @package Stash
* @author Robert Hafner <tedivm@tedivm.com>
*/
class UnavailableDriverTest extends \PHPUnit_Framework_TestCase
class UnavailableDriverTest extends \PHPUnit\Framework\TestCase
{
/**
* @expectedException Stash\Exception\RuntimeException
Expand Down
2 changes: 1 addition & 1 deletion tests/Stash/Test/DriverListTest.php
Expand Up @@ -17,7 +17,7 @@
* @package Stash
* @author Robert Hafner <tedivm@tedivm.com>
*/
class DriverListTest extends \PHPUnit_Framework_TestCase
class DriverListTest extends \PHPUnit\Framework\TestCase
{
public function testGetAvailableDrivers()
{
Expand Down
23 changes: 16 additions & 7 deletions tests/Stash/Test/ItemLoggerTest.php
Expand Up @@ -21,7 +21,7 @@
* @package Stash
* @author Robert Hafner <tedivm@tedivm.com>
*/
class ItemLoggerTest extends \PHPUnit_Framework_TestCase
class ItemLoggerTest extends \PHPUnit\Framework\TestCase
{
protected function getItem($key, $exceptionDriver = false)
{
Expand Down Expand Up @@ -60,8 +60,11 @@ public function testGet()
// triggerlogging
$item->get('test_key');

$this->assertInstanceOf('Stash\Test\Exception\TestException',
$logger->lastContext['exception'], 'Logger was passed exception in event context.');
$this->assertInstanceOf(
'Stash\Test\Exception\TestException',
$logger->lastContext['exception'],
'Logger was passed exception in event context.'
);

$this->assertTrue(strlen($logger->lastMessage) > 0, 'Logger message set after "get" exception.');
$this->assertEquals('critical', $logger->lastLevel, 'Exceptions logged as critical.');
Expand All @@ -77,8 +80,11 @@ public function testSet()
// triggerlogging
$item->set('test_key')->save();

$this->assertInstanceOf('Stash\Test\Exception\TestException',
$logger->lastContext['exception'], 'Logger was passed exception in event context.');
$this->assertInstanceOf(
'Stash\Test\Exception\TestException',
$logger->lastContext['exception'],
'Logger was passed exception in event context.'
);
$this->assertTrue(strlen($logger->lastMessage) > 0, 'Logger message set after "set" exception.');
$this->assertEquals('critical', $logger->lastLevel, 'Exceptions logged as critical.');
}
Expand All @@ -93,8 +99,11 @@ public function testClear()
// triggerlogging
$item->clear();

$this->assertInstanceOf('Stash\Test\Exception\TestException',
$logger->lastContext['exception'], 'Logger was passed exception in event context.');
$this->assertInstanceOf(
'Stash\Test\Exception\TestException',
$logger->lastContext['exception'],
'Logger was passed exception in event context.'
);
$this->assertTrue(strlen($logger->lastMessage) > 0, 'Logger message set after "clear" exception.');
$this->assertEquals('critical', $logger->lastLevel, 'Exceptions logged as critical.');
}
Expand Down
73 changes: 49 additions & 24 deletions tests/Stash/Test/SessionTest.php
Expand Up @@ -18,7 +18,7 @@
* @package Stash
* @author Robert Hafner <tedivm@tedivm.com>
*/
class SessionTest extends \PHPUnit_Framework_TestCase
class SessionTest extends \PHPUnit\Framework\TestCase
{
protected $testClass = '\Stash\Session';
protected $poolClass = '\Stash\Pool';
Expand All @@ -38,13 +38,21 @@ public function testReadAndWrite()
{
$session = $this->getSession();

$this->assertSame('', $session->read('session_id'),
'Empty session returns empty string.');

$this->assertTrue($session->write('session_id', 'session_data'),
'Data was written to the session.');
$this->assertSame('session_data', $session->read('session_id'),
'Active session returns session data.');
$this->assertSame(
'',
$session->read('session_id'),
'Empty session returns empty string.'
);

$this->assertTrue(
$session->write('session_id', 'session_data'),
'Data was written to the session.'
);
$this->assertSame(
'session_data',
$session->read('session_id'),
'Active session returns session data.'
);
}

public function testOpen()
Expand All @@ -62,8 +70,10 @@ public function testOpen()
$DataA = $sessionA->read('shared_id');
$DataB = $sessionB->read('shared_id');

$this->assertTrue($DataA != $DataB,
'Sessions with different paths do not share data.');
$this->assertTrue(
$DataA != $DataB,
'Sessions with different paths do not share data.'
);

$pool = $this->getPool();

Expand All @@ -78,15 +88,19 @@ public function testOpen()
$DataA = $sessionA->read('shared_id');
$DataB = $sessionB->read('shared_id');

$this->assertTrue($DataA != $DataB,
'Sessions with different names do not share data.');
$this->assertTrue(
$DataA != $DataB,
'Sessions with different names do not share data.'
);
}

public function testClose()
{
$session = $this->getSession();
$this->assertTrue($session->close(),
'Session was closed');
$this->assertTrue(
$session->close(),
'Session was closed'
);
}

public function testDestroy()
Expand All @@ -95,14 +109,22 @@ public function testDestroy()

$session->write('session_id', 'session_data');
$session->write('session_id', 'session_data');
$this->assertSame('session_data', $session->read('session_id'),
'Active session returns session data.');

$this->assertTrue($session->destroy('session_id'),
'Data was removed from the session.');

$this->assertSame('', $session->read('session_id'),
'Destroyed session returns empty string.');
$this->assertSame(
'session_data',
$session->read('session_id'),
'Active session returns session data.'
);

$this->assertTrue(
$session->destroy('session_id'),
'Data was removed from the session.'
);

$this->assertSame(
'',
$session->read('session_id'),
'Destroyed session returns empty string.'
);
}

public function testGarbageCollect()
Expand All @@ -117,8 +139,11 @@ public function testGarbageCollect()
$sessionB->gc(null);

$sessionC = $this->getSession($pool);
$this->assertSame('', $sessionC->read('session_id'),
'Purged session returns empty string.');
$this->assertSame(
'',
$sessionC->read('session_id'),
'Purged session returns empty string.'
);
}

protected function getSession($pool = null)
Expand Down
2 changes: 1 addition & 1 deletion tests/Stash/Test/UtilitiesTest.php
Expand Up @@ -18,7 +18,7 @@
* @package Stash
* @author Robert Hafner <tedivm@tedivm.com>
*/
class UtilitiesTest extends \PHPUnit_Framework_TestCase
class UtilitiesTest extends \PHPUnit\Framework\TestCase
{
public function testEncoding()
{
Expand Down

0 comments on commit 5e324b4

Please sign in to comment.