/** * Sets up the fixture. * * This method is called before a test is executed. * * @return void * * @since 1.0 */ protected function setUp() { // Dummy object for testing static::$object = $this; parent::setUp(); static::$className = '\\Joomla\\Session\\Storage'; }
public static function init($channel, $filename) { $logger = new MongoLog($channel); $stream = new RotatingFileHandler($filename, 0, MongoLog::DEBUG); $stream->setFormatter(new LineFormatter("%datetime% [%channel%] %level_name% %message% %context%\n", "Y-m-d H:i:s")); $logger->pushHandler($stream); static::$object = $logger; }
/** * @depends testStoreNewWithKey */ public function testFetchOk() { $command = (new Command\Builder\FetchObject(static::$riak))->buildLocation(static::$key, 'users')->build(); $response = $command->execute(); $this->assertEquals('200', $response->getCode()); $this->assertInstanceOf('Basho\\Riak\\Object', $response->getObject()); $this->assertEquals('some_data', $response->getObject()->getData()); $this->assertNotEmpty($response->getObject()->getVclock()); static::$object = $response->getObject(); }
/** * Statically creates a new MediaObject instance * * @param string $content Its content * @param string $media Its media * @param array $attributes The media object's attributes * @return MediaObject */ public static function create($content, $media = null, $attributes = array()) { static::$object = new static($content); if ($media) { static::$object->with_image($media); } if ($attributes) static::$object->attributes = $attributes; return static::$object; }
/** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. * * @return void * * @since 1.0 */ protected function setUp() { if (!class_exists('Memcached')) { $this->markTestSkipped('The Memcached class does not exist.'); return; } // Create the caching object static::$object = Storage::getInstance('Memcached'); // Parent contains the rest of the setup parent::setUp(); }
/** * 启用日志 * * @param array $arr * @return void */ static function open($arr = null) { if (!isset(static::$object)) { static::init(); static::$object = true; } static::$open = true; if ($arr) { static::$enable = $arr; } }
public static function generate(Reflectable $object) { static::$object = $object; static::$reflection = $object::getReflection(); $factory = DocBlockFactory::createInstance(); $docblock = $factory->create(static::$reflection->getDocComment()); if ($docblock->hasTag('property')) { $properties = $docblock->getTagsByName('property'); foreach ($properties as $property) { static::renderField($property); } } }
/** * @depends testStoreObjectWithIndexes */ public function testFetchObjectWithIndexes() { $command = (new Command\Builder\FetchObject(static::$riak))->buildLocation(static::$key, 'Users', static::LEVELDB_BUCKET_TYPE)->build(); $response = $command->execute(); $this->assertEquals('200', $response->getCode()); $this->assertInstanceOf('Basho\\Riak\\Object', $response->getObject()); $this->assertEquals('person', $response->getObject()->getData()); $this->assertNotEmpty($response->getObject()->getVClock()); $indexes = $response->getObject()->getIndexes(); $this->assertEquals($indexes['lucky_numbers_int'], [42, 64]); $this->assertEquals($indexes['lastname_bin'], ['Knuth']); static::$object = $response->getObject(); static::$vclock = $response->getObject()->getVClock(); }
public static function reset() { static::$object = null; $clname = function_exists('get_called_class') ? get_called_class() : static::$class; $class = new ReflectionClass($clname); $arr = array_keys($class->getStaticProperties()); unset($arr[array_search('class', $arr)], $arr[array_search('stack', $arr)], $arr[array_search('object', $arr)], $arr[array_search('container', $arr)], $arr[array_search('variables', $arr)]); static::$variables = $arr; unset($arr[array_search('stack', $arr)]); foreach ($arr as $var) { static::${$var} = null; } static::$container = array(); }
/** * @depends testStoreNewWithKey */ public function testFetchOk() { $command = (new Command\Builder\FetchObject(static::$riak))->buildLocation(static::$key, 'users')->build(); $response = $command->execute(); $this->assertEquals('200', $response->getCode()); $this->assertInstanceOf('Basho\\Riak\\Object', $response->getObject()); $this->assertEquals('some_data', $response->getObject()->getData()); $this->assertNotEmpty($response->getObject()->getVclock()); // confirm we are using the HTTP api bridge if (static::$riak->getApi() instanceof \Basho\Riak\Api\Http) { $headers = static::$riak->getApi()->getResponseHeaders(); $this->assertNotEmpty($headers); $this->assertNotEmpty($headers["Last-Modified"]); $this->assertNotEmpty(new \DateTime($headers["Last-Modified"])); } static::$object = $response->getObject(); }
/** * @throws NotFoundHttpException * @throws ServerErrorHttpException */ public function init() { if (false === Yii::$app->request->isAjax) { throw new NotFoundHttpException('Page not found'); } $catId = Yii::$app->request->post('cat-id'); if (null !== Category::findOne(['id' => $catId])) { $this->categoryId = $catId; } else { throw new ServerErrorHttpException("Can't find Category with id {$catId}"); } if (true === empty(static::$object)) { static::$object = Object::getForClass(Product::className()); } $this->action = Yii::$app->request->post('action', ''); $this->items = Yii::$app->request->post('mc-items', []); parent::init(); }
public static function init($object) { static::$object = $object; }
/** * Setando o objeto * * @access public * @param object $object * @return void */ public static function setObject($object) { static::$object = $object; }
public static function setUpBeforeClass() { static::$object = new \stdClass(); static::$object->str = 'coincoin'; }