Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

Commit

Permalink
Add tests with mocking to cover changes from the PR
Browse files Browse the repository at this point in the history
  • Loading branch information
michalbundyra committed Aug 28, 2019
1 parent 50d1077 commit ff370bf
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions test/Psr/SimpleCache/SimpleCacheDecoratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -791,4 +791,30 @@ public function testUseTtlFromOptionsWhenNotProvidedOnSetMultiple()
self::assertSame(20, $storage->ttl['bar']);
self::assertSame(20, $storage->getOptions()->getTtl());
}

public function testUseTtlFromOptionsOnSetMocking()
{
$this->options->getTtl()->willReturn(40);
$this->options->setTtl(40)->will([$this->options, 'reveal']);

$this->options->setTtl(null)->shouldNotBeCalled();

$this->storage->getOptions()->will([$this->options, 'reveal']);
$this->storage->setItem('foo', 'bar')->willReturn(true);

self::assertTrue($this->cache->set('foo', 'bar'));
}

public function testUseTtlFromOptionsOnSetMultipleMocking()
{
$this->options->getTtl()->willReturn(40);
$this->options->setTtl(40)->will([$this->options, 'reveal']);

$this->options->setTtl(null)->shouldNotBeCalled();

$this->storage->getOptions()->will([$this->options, 'reveal']);
$this->storage->setItems(['foo' => 'bar', 'boo' => 'baz'])->willReturn([]);

self::assertTrue($this->cache->setMultiple(['foo' => 'bar', 'boo' => 'baz']));
}
}

0 comments on commit ff370bf

Please sign in to comment.