Skip to content

Commit

Permalink
fixed warnings about protected static function
Browse files Browse the repository at this point in the history
  • Loading branch information
garrettw committed Aug 10, 2017
1 parent 87e3e8f commit e262eff
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion core/Pimf/Cache/Storages/Dba.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public function put($key, $value, $minutes)
return;
}

$value = self::expiration($minutes) . serialize($value);
$value = $this->expiration($minutes) . serialize($value);

if (true === $this->has($key)) {
return dba_replace($key, $value, $this->dba);
Expand Down
2 changes: 1 addition & 1 deletion core/Pimf/Cache/Storages/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public function put($key, $value, $minutes)
return null;
}

$value = self::expiration($minutes) . serialize($value);
$value = $this->expiration($minutes) . serialize($value);

return file_put_contents($this->path . $key, $value, LOCK_EX);
}
Expand Down
2 changes: 1 addition & 1 deletion core/Pimf/Cache/Storages/Pdo.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public function put($key, $value, $minutes)
{
$key = $this->key . $key;
$value = serialize($value);
$expiration = self::expiration($minutes);
$expiration = $this->expiration($minutes);

try {
$sth = $this->pdo->prepare(
Expand Down
2 changes: 1 addition & 1 deletion core/Pimf/Cache/Storages/Storage.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ public function offsetUnset($key)
*
* @return int
*/
protected static function expiration($minutes)
public function expiration($minutes)
{
return time() + ($minutes * 60);
}
Expand Down
14 changes: 10 additions & 4 deletions tests/Pimf/Cache/PdoTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,12 @@ public function testSetMethodProperlyCallsPdo()
{
$store = $this->getStore();

$store->expects($this->any())->method('expiration')->with(60 * 60);
$cache = $this->getMockBuilder('\Pimf\Cache\Storages\Pdo')->setConstructorArgs(array(
$store,
'key.'
))->getMock();

$cache = new \Pimf\Cache\Storages\Pdo($store, 'key.');
$cache->expects($this->any())->method('expiration')->with(60 * 60);

$cache->put('foo', 'foo', 60);
}
Expand All @@ -65,9 +68,12 @@ public function testSetMethodProperlyCallsPdoForNumerics()
{
$store = $this->getStore();

$store->expects($this->any())->method('expiration')->with(60 * 60);
$cache = $this->getMockBuilder('\Pimf\Cache\Storages\Pdo')->setConstructorArgs(array(
$store,
'key.'
))->getMock();

$cache = new \Pimf\Cache\Storages\Pdo($store, 'key.');
$cache->expects($this->any())->method('expiration')->with(60 * 60);

$cache->put('foo', 1, 60);
}
Expand Down

0 comments on commit e262eff

Please sign in to comment.