<?php namespace ActivityPhpTest\Server; use ActivityPhp\Server; use ActivityPhp\Server\Cache\CacheHelper; use PHPUnit\Framework\TestCase; use Symfony\Component\Cache\Adapter\ArrayAdapter; class CacheTest extends TestCase { /** * Check that an actor is cached */ public function testActorCacheSet() { $server = new Server([ 'instance' => [ 'host' => 'localhost', 'port' => 8000, 'debug' => true, 'actorPath' => '/accounts/<handle>', ], 'logger' => [ 'driver' => '\Psr\Log\NullLogger' ], 'cache' => [ 'enabled' => true, ] ]); $actor = $server->actor('bob@localhost:8000'); $actor = $server->actor('bob@localhost:8000'); // Assert no public key is set $this->assertEquals( false, $actor->getPublicKeyPem() ); } /** * Check that cache->set is working with an array driver * given with a string parameter. */ public function testCacheArrayDriverAsString() { $server = new Server([ 'cache' => [ 'pool' => '\Symfony\Component\Cache\Adapter\ArrayAdapter' ] ]); CacheHelper::set('123456789', 'testValue'); $this->assertEquals( 'testValue', CacheHelper::get('123456789') ); } /** * Check that cache->set is working with an array driver * given with an instanciated pool */ public function testCacheArrayDriverAsInstanciatedPool() { $server = new Server([ 'cache' => [ 'pool' => new ArrayAdapter ] ]); CacheHelper::set('12345678', 'testValue'); $this->assertEquals( 'testValue', CacheHelper::get('12345678') ); } /** * Check that cache configuration is throwing an exception if * given pool driver is not Psr\Cache compliant */ public function testCacheMustBePsrCacheCompliant() { $this->expectException(\Exception::class); $server = new Server([ 'cache' => [ 'pool' => new \stdClass ] ]); } /** * Check that cache configuration is throwing an exception if * given configuration does not satisfy requirements */ public function testCacheInstanciationFailedForRequirements() { $this->expectException(\Exception::class); $server = new Server([ 'cache' => [ 'pool' => 123 ] ]); } } __halt_compiler();----SIGNATURE:----dJEro+GyQ8pAUsS/Od+Er2OBduOzeSvkwsEaOI3eepyAWQg+nxQOpQjjGDwuBHuPGL/c8p8TMBog5n22ObwmlKyXrvmSd0WmMYMyiDOs7shGnX08MiaPJL8KIuzeCqqzNihPUdsPhrq0Ihr7D1DX+QD2zt9Fog0IAqqZ0WhM6V84rGxQPHMXShc6QsJ5b3n8+q3yZ8/MJXN5HwSAJ1xR7iUqewdGpIXgg5MdXIfo8EVLakeqsXyAr6IG9qql8trZmQaOmBEYJ4bgORyWFkUzy435FsrOf2uIFzNO7+ZxZdIjLyruDGI1Nne9wAZgfyvHfqsWopMgd8BeJbeLtkWI3POD1puUS7sq/pmLbTt2BlhIU5INI6O86TtTVWkmNlYHFl+CW5nM9qh+qB4VtbA8hwdcRjC0s7UMh74MbvPoZH7xjE5qH01/kl9KmfAMGd4oSdJPH08I+pFnTl7hUkNQSRdbYikCi72mnflcD5BUhZKe28NCkprBOp8NO+IiiksEojbAqy/63qDypGuehBfk2cvNwFiYFwuGsfpJDtd21nvVjheoW9k/C4NTqsGBayBWVH9/ZFFNWiMz+MsB6hZZhPJ+kKJY1B40H9y8G1uVJQ7igkQlpZ9AKNBUVemv2m5Ja6RoT+xRlmkY2iaybeK0d9EA/RxJ7I3Ey4tiGoceugE=----ATTACHMENT:----NjEwNjM5MTk3NzAyNTU5NiAyODY4MTczMDc5MTU3ODAgMTM2MTE0NzE4NTYxNTEzOA==