Skip to content

Commit

Permalink
Updated tests
Browse files Browse the repository at this point in the history
  • Loading branch information
andrey-helldar committed Jan 15, 2024
1 parent 4646632 commit 163e37f
Show file tree
Hide file tree
Showing 6 changed files with 210 additions and 48 deletions.
43 changes: 35 additions & 8 deletions tests/Cache/NotWhen/Simple/ArrayTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,20 +52,47 @@ public function testForget()
$this->assertNull($this->cache()->get());
}

public function testFlush()
public function testFlushByKeys()
{
$tags = Cache::make()->tags('foo', 'bar');
$cache = (clone $tags)->key('qwerty');
$cache1 = Cache::make()->when($this->when)->key('foo');
$cache2 = Cache::make()->when($this->when)->key('bar');

$this->assertNull($cache->get());
$this->assertNull($cache1->get());
$this->assertNull($cache2->get());

$cache->put('asd');
$cache1->put('qwe');
$cache2->put('rty');

$this->assertSame('asd', $cache->get());
$this->assertNull($cache1->get());
$this->assertNull($cache2->get());

$tags->flush();
$cache1->flush();

$this->assertNull($cache->get());
$this->assertNull($cache1->get());
$this->assertNull($cache2->get());
}

public function testFlushByTags()
{
$tags1 = Cache::make()->when($this->when)->tags('some1');
$tags2 = Cache::make()->when($this->when)->tags('some2');

$cache1 = (clone $tags1)->key('foo');
$cache2 = (clone $tags2)->key('bar');

$this->assertNull($cache1->get());
$this->assertNull($cache2->get());

$cache1->put('qwe');
$cache2->put('rty');

$this->assertNull($cache1->get());
$this->assertNull($cache2->get());

$tags1->flush();

$this->assertNull($cache1->get());
$this->assertNull($cache2->get());
}

public function testHas()
Expand Down
43 changes: 35 additions & 8 deletions tests/Cache/NotWhen/Simple/FileTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,20 +52,47 @@ public function testForget()
$this->assertNull($this->cache()->get());
}

public function testFlush()
public function testFlushByKeys()
{
$tags = Cache::make()->tags('foo', 'bar');
$cache = (clone $tags)->key('qwerty');
$cache1 = Cache::make()->when($this->when)->key('foo');
$cache2 = Cache::make()->when($this->when)->key('bar');

$this->assertNull($cache->get());
$this->assertNull($cache1->get());
$this->assertNull($cache2->get());

$cache->put('asd');
$cache1->put('qwe');
$cache2->put('rty');

$this->assertSame('asd', $cache->get());
$this->assertNull($cache1->get());
$this->assertNull($cache2->get());

$tags->flush();
$cache1->flush();

$this->assertNull($cache->get());
$this->assertNull($cache1->get());
$this->assertNull($cache2->get());
}

public function testFlushByTags()
{
$tags1 = Cache::make()->when($this->when)->tags('some1');
$tags2 = Cache::make()->when($this->when)->tags('some2');

$cache1 = (clone $tags1)->key('foo');
$cache2 = (clone $tags2)->key('bar');

$this->assertNull($cache1->get());
$this->assertNull($cache2->get());

$cache1->put('qwe');
$cache2->put('rty');

$this->assertNull($cache1->get());
$this->assertNull($cache2->get());

$tags1->flush();

$this->assertNull($cache1->get());
$this->assertNull($cache2->get());
}

public function testHas()
Expand Down
43 changes: 35 additions & 8 deletions tests/Cache/NotWhen/Simple/RedisTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,20 +74,47 @@ public function testForget()
$this->assertNull($this->cache(['cache'])->get());
}

public function testFlush()
public function testFlushByKeys()
{
$tags = Cache::make()->tags('foo', 'bar');
$cache = (clone $tags)->key('qwerty');
$cache1 = Cache::make()->when($this->when)->key('foo');
$cache2 = Cache::make()->when($this->when)->key('bar');

$this->assertNull($cache->get());
$this->assertNull($cache1->get());
$this->assertNull($cache2->get());

$cache->put('asd');
$cache1->put('qwe');
$cache2->put('rty');

$this->assertSame('asd', $cache->get());
$this->assertNull($cache1->get());
$this->assertNull($cache2->get());

$tags->flush();
$cache1->flush();

$this->assertNull($cache->get());
$this->assertNull($cache1->get());
$this->assertNull($cache2->get());
}

public function testFlushByTags()
{
$tags1 = Cache::make()->when($this->when)->tags('some1');
$tags2 = Cache::make()->when($this->when)->tags('some2');

$cache1 = (clone $tags1)->key('foo');
$cache2 = (clone $tags2)->key('bar');

$this->assertNull($cache1->get());
$this->assertNull($cache2->get());

$cache1->put('qwe');
$cache2->put('rty');

$this->assertNull($cache1->get());
$this->assertNull($cache2->get());

$tags1->flush();

$this->assertNull($cache1->get());
$this->assertNull($cache2->get());
}

public function testHas()
Expand Down
43 changes: 35 additions & 8 deletions tests/Cache/When/Simple/ArrayTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,20 +62,47 @@ public function testForget()
$this->assertNull($this->cache()->get());
}

public function testFlush()
public function testFlushByKeys()
{
$tags = Cache::make()->tags('foo', 'bar');
$cache = (clone $tags)->key('qwerty');
$cache1 = Cache::make()->key('foo');
$cache2 = Cache::make()->key('bar');

$this->assertNull($cache->get());
$this->assertNull($cache1->get());
$this->assertNull($cache2->get());

$cache->put('asd');
$cache1->put('qwe');
$cache2->put('rty');

$this->assertSame('asd', $cache->get());
$this->assertSame('qwe', $cache1->get());
$this->assertSame('rty', $cache2->get());

$tags->flush();
$cache1->flush();

$this->assertNull($cache->get());
$this->assertNull($cache1->get());
$this->assertNull($cache2->get());
}

public function testFlushByTags()
{
$tags1 = Cache::make()->tags('some1');
$tags2 = Cache::make()->tags('some2');

$cache1 = (clone $tags1)->key('foo');
$cache2 = (clone $tags2)->key('bar');

$this->assertNull($cache1->get());
$this->assertNull($cache2->get());

$cache1->put('qwe');
$cache2->put('rty');

$this->assertSame('qwe', $cache1->get());
$this->assertSame('rty', $cache2->get());

$tags1->flush();

$this->assertNull($cache1->get());
$this->assertSame('rty', $cache2->get());
}

public function testHas()
Expand Down
43 changes: 35 additions & 8 deletions tests/Cache/When/Simple/FileTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,20 +64,47 @@ public function testForget()
$this->assertNull($this->cache()->get());
}

public function testFlush()
public function testFlushByKeys()
{
$tags = Cache::make()->tags('foo', 'bar');
$cache = (clone $tags)->key('qwerty');
$cache1 = Cache::make()->key('foo');
$cache2 = Cache::make()->key('bar');

$this->assertNull($cache->get());
$this->assertNull($cache1->get());
$this->assertNull($cache2->get());

$cache->put('asd');
$cache1->put('qwe');
$cache2->put('rty');

$this->assertSame('asd', $cache->get());
$this->assertSame('qwe', $cache1->get());
$this->assertSame('rty', $cache2->get());

$tags->flush();
$cache1->flush();

$this->assertNull($cache->get());
$this->assertNull($cache1->get());
$this->assertNull($cache2->get());
}

public function testFlushByTags()
{
$tags1 = Cache::make()->tags('some1');
$tags2 = Cache::make()->tags('some2');

$cache1 = (clone $tags1)->key('foo');
$cache2 = (clone $tags2)->key('bar');

$this->assertNull($cache1->get());
$this->assertNull($cache2->get());

$cache1->put('qwe');
$cache2->put('rty');

$this->assertSame('qwe', $cache1->get());
$this->assertSame('rty', $cache2->get());

$tags1->flush();

$this->assertNull($cache1->get());
$this->assertNull($cache2->get());
}

public function testHas()
Expand Down
43 changes: 35 additions & 8 deletions tests/Cache/When/Simple/RedisTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,20 +73,47 @@ public function testForget()
$this->assertNull($this->cache(['cache'])->get());
}

public function testFlush()
public function testFlushByKeys()
{
$tags = Cache::make()->tags('foo', 'bar');
$cache = (clone $tags)->key('qwerty');
$cache1 = Cache::make()->key('foo');
$cache2 = Cache::make()->key('bar');

$this->assertNull($cache->get());
$this->assertNull($cache1->get());
$this->assertNull($cache2->get());

$cache->put('asd');
$cache1->put('qwe');
$cache2->put('rty');

$this->assertSame('asd', $cache->get());
$this->assertSame('qwe', $cache1->get());
$this->assertSame('rty', $cache2->get());

$tags->flush();
$cache1->flush();

$this->assertNull($cache->get());
$this->assertNull($cache1->get());
$this->assertNull($cache2->get());
}

public function testFlushByTags()
{
$tags1 = Cache::make()->tags('some1');
$tags2 = Cache::make()->tags('some2');

$cache1 = (clone $tags1)->key('foo');
$cache2 = (clone $tags2)->key('bar');

$this->assertNull($cache1->get());
$this->assertNull($cache2->get());

$cache1->put('qwe');
$cache2->put('rty');

$this->assertSame('qwe', $cache1->get());
$this->assertSame('rty', $cache2->get());

$tags1->flush();

$this->assertNull($cache1->get());
$this->assertSame('rty', $cache2->get());
}

public function testHas()
Expand Down

0 comments on commit 163e37f

Please sign in to comment.