Skip to content

Commit

Permalink
Merge pull request #3 from hmerritt/v1.0.1
Browse files Browse the repository at this point in the history
Added unit tests for Cache functions
  • Loading branch information
hmerritt authored Feb 25, 2020
2 parents 3eb94dc + 18aeb9e commit 0145be3
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 17 deletions.
3 changes: 1 addition & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
"php-coveralls/php-coveralls": "^2.2"
},
"scripts": {
"test": "php vendor/phpunit/phpunit/phpunit",
"test-coverage": "php vendor/phpunit/phpunit/phpunit --coverage-clover build/logs/clover.xml"
"test": "php vendor/phpunit/phpunit/phpunit"
},
"autoload": {
"psr-4": {
Expand Down
10 changes: 0 additions & 10 deletions src/Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,6 @@ public function add(string $key, $value)
return true;
}

/**
* Counts all files in the cache
*
* @return int
*/
public function count(): int
{
return $this->cache->count();
}

/**
* Deletes an item from the cache
*
Expand Down
33 changes: 28 additions & 5 deletions tests/CacheTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,40 @@

class CacheTest extends TestCase {

public function testCache()
public function testAddToCache()
{
$cache = new Cache;
$cache_testStore = [
$testData = [
"title" => "Interstellar"
];

$cache->add("test", $cache_testStore);
$cache_testFile = $cache->get("test");
$cache->add("test", $testData);
$testFile = $cache->get("test");

$this->assertEquals($cache_testStore, $cache_testFile->film);
$this->assertEquals($testData, $testFile->film);

$cache->delete("test");
}

public function testHasCache()
{
$cache = new Cache;
$cache->add("testHas", [ "test" => "has" ]);

$this->assertEquals(true, $cache->has("testHas"));
$this->assertEquals(false, $cache->has("testHasNot"));

$cache->delete("testHas");
}

public function testDeleteFromCache()
{
$cache = new Cache;
$cache->add("testHas", [ "test" => "has" ]);

$this->assertEquals(true, $cache->has("testHas"));
$cache->delete("testHas");
$this->assertEquals(false, $cache->has("testHas"));
}

}

0 comments on commit 0145be3

Please sign in to comment.