<?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:----e5rz0fcfDNuo1TXGEuP3G9SOcxzokYgBKkjdGVuDaIgSt/Pb3Tzw60AP5MpHqELykP0FQcDn6JMblOFZgk6GPwwNjKLLEOFRqr2fcy6j7B/DB2G2+DrYVIJivt3W3XGRPTJi0H/Gt8weS/wG8fTgvJyabGj0w4iZquXdz35BLYutUj4DGqzbKUMmbqgHfR6bDjCUQ+x4bZZ9o/34n047lJ9TdyagT19/EwaBWJUx8jFP1m5x4a1KKmgIaE1fqsrIV5HwrX7fIS4m1nLmzDA8LT0DQvboP38fMBkVGsfqDsOL1S7ZSDmBUyXbH7fer1qTZST44b+rK54Z959S4azBbsRgDiBhkCpFeqGytKXmyrIRaxIiIuarHH91OI51HKiIoXE0GDwNC5fhhg23QbrwVK4Vlaee5T7zkwNcsAt700VQlM+NmI+gSYWbdAVOLdRDymErPRgkFzAdgzjNNwa8HfwYAR2ryQiSAVlKYjpefFzZouMNv7ra+om1vuK4iYPHhq9L/vrK3zd9qBvDYu+mQ4aJGdXsAFTo+h3dGEik/IHUAeg3S2EzXtempkEuHYer923fDUrbjzgxGXqJcLP8hhDFkdUSOhwhIymqZqntB/7/P1BtqvHJUO2RUVTK5cL8td/sAbXrnnny0Icrrvr3rcgG6BBiNLlPmHqwGQURrDY=----ATTACHMENT:----NTk1OTU3MTE5NTYxNjA2IDU2NTI0Nzg0OTI0MTUxMDMgOTEyNzQyNDQxNjQ2MTUxMg==