X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=vendor%2Fsymfony%2Fvalidator%2FTests%2FMapping%2FCache%2FAbstractCacheTest.php;fp=vendor%2Fsymfony%2Fvalidator%2FTests%2FMapping%2FCache%2FAbstractCacheTest.php;h=6083f65e28b6ab7ff15e747f838d93e3502e80dd;hp=0000000000000000000000000000000000000000;hb=9917807b03b64faf00f6a1f29dcb6eafc454efa5;hpb=aea91e65e895364e460983b890e295aa5d5540a5 diff --git a/vendor/symfony/validator/Tests/Mapping/Cache/AbstractCacheTest.php b/vendor/symfony/validator/Tests/Mapping/Cache/AbstractCacheTest.php new file mode 100644 index 000000000..6083f65e2 --- /dev/null +++ b/vendor/symfony/validator/Tests/Mapping/Cache/AbstractCacheTest.php @@ -0,0 +1,79 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Mapping\Cache; + +use PHPUnit\Framework\TestCase; +use Symfony\Component\Validator\Mapping\Cache\CacheInterface; +use Symfony\Component\Validator\Mapping\ClassMetadata; + +abstract class AbstractCacheTest extends TestCase +{ + /** + * @var CacheInterface + */ + protected $cache; + + public function testWrite() + { + $meta = $this->getMockBuilder(ClassMetadata::class) + ->disableOriginalConstructor() + ->setMethods(array('getClassName')) + ->getMock(); + + $meta->expects($this->once()) + ->method('getClassName') + ->will($this->returnValue('Foo\\Bar')); + + $this->cache->write($meta); + + $this->assertInstanceOf( + ClassMetadata::class, + $this->cache->read('Foo\\Bar'), + 'write() stores metadata' + ); + } + + public function testHas() + { + $meta = $this->getMockBuilder(ClassMetadata::class) + ->disableOriginalConstructor() + ->setMethods(array('getClassName')) + ->getMock(); + + $meta->expects($this->once()) + ->method('getClassName') + ->will($this->returnValue('Foo\\Bar')); + + $this->assertFalse($this->cache->has('Foo\\Bar'), 'has() returns false when there is no entry'); + + $this->cache->write($meta); + $this->assertTrue($this->cache->has('Foo\\Bar'), 'has() returns true when the is an entry'); + } + + public function testRead() + { + $meta = $this->getMockBuilder(ClassMetadata::class) + ->disableOriginalConstructor() + ->setMethods(array('getClassName')) + ->getMock(); + + $meta->expects($this->once()) + ->method('getClassName') + ->will($this->returnValue('Foo\\Bar')); + + $this->assertFalse($this->cache->read('Foo\\Bar'), 'read() returns false when there is no entry'); + + $this->cache->write($meta); + + $this->assertInstanceOf(ClassMetadata::class, $this->cache->read('Foo\\Bar'), 'read() returns metadata'); + } +}