/** * @throws \Axvf\Threadable\Exceptions\NoSuchProcessException */ public function testStart() { $Class = $this->getAbstraction(); $Class->spawnThread(); $this->assertGreaterThan(1, \Axvf\Threadable\ProcessControl::getProcessIdsOfThreadKey($Class->getThreadKey())[0]); $this->assertTrue(Redis::client()->exists($Class->getThreadKey())); $Class->killThread(); $this->assertFalse(Redis::client()->exists($Class->getThreadKey())); }
/** * @return \Redis */ protected function getRedisInstance() { return Redis::client(); }
<?php namespace Axvf\Threadable; use Axvf\Redis\Redis; use Axvf\Threadable\Exceptions\NoSuchThreadableObjectException; $Autoloader = dirname(__FILE__) . '/../../../autoload.php'; require_once $Autoloader; /** * @var ThreadableInterface $ThreadableObject */ $ThreadableObject = Redis::client()->get(CommandParse::getCurrentThreadKey()); /** * Try a second time to get the object from redis if * the object isn't an instance of ThreadableInterface */ if (!$ThreadableObject instanceof ThreadableInterface) { sleep(1); $ThreadableObject = Redis::client()->get(CommandParse::getCurrentThreadKey()); if (!$ThreadableObject instanceof ThreadableInterface) { throw new NoSuchThreadableObjectException($ThreadableObject); } } $ThreadableObject->start();
/** * @expectedException Axvf\Redis\Exceptions\RedisUnsubscribeException */ public function testUnsubscribe() { Redis::client()->unsubscribe(); }