Thanks to visit codestin.com
Credit goes to github.com

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
[Cache] Apply NullAdapter as Null Object
  • Loading branch information
roukmoute authored and derrabus committed Apr 12, 2021
commit f6818eb7acd062d72cf9d1269286ba831bd5bfcb
6 changes: 3 additions & 3 deletions src/Symfony/Component/Cache/Adapter/NullAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public function deleteItems(array $keys)
*/
public function save(CacheItemInterface $item)
{
return false;
return true;
}

/**
Expand All @@ -124,7 +124,7 @@ public function save(CacheItemInterface $item)
*/
public function saveDeferred(CacheItemInterface $item)
{
return false;
return true;
}

/**
Expand All @@ -134,7 +134,7 @@ public function saveDeferred(CacheItemInterface $item)
*/
public function commit()
{
return false;
return true;
}

/**
Expand Down
8 changes: 4 additions & 4 deletions src/Symfony/Component/Cache/Tests/Adapter/NullAdapterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public function testSave()
$this->assertFalse($item->isHit());
$this->assertNull($item->get(), "Item's value must be null when isHit is false.");

$this->assertFalse($adapter->save($item));
$this->assertTrue($adapter->save($item));
}

public function testDeferredSave()
Expand All @@ -124,7 +124,7 @@ public function testDeferredSave()
$this->assertFalse($item->isHit());
$this->assertNull($item->get(), "Item's value must be null when isHit is false.");

$this->assertFalse($adapter->saveDeferred($item));
$this->assertTrue($adapter->saveDeferred($item));
}

public function testCommit()
Expand All @@ -135,7 +135,7 @@ public function testCommit()
$this->assertFalse($item->isHit());
$this->assertNull($item->get(), "Item's value must be null when isHit is false.");

$this->assertFalse($adapter->saveDeferred($item));
$this->assertFalse($this->createCachePool()->commit());
$this->assertTrue($adapter->saveDeferred($item));
$this->assertTrue($this->createCachePool()->commit());
}
}