本文整理汇总了PHP中Context::pop方法的典型用法代码示例。如果您正苦于以下问题:PHP Context::pop方法的具体用法?PHP Context::pop怎么用?PHP Context::pop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Context
的用法示例。
在下文中一共展示了Context::pop方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testAddItemInInnerScope
public function testAddItemInInnerScope()
{
$this->context->push();
$this->context->set('test', 'test');
$this->assertEquals('test', $this->context->get('test'));
$this->context->pop();
$this->assertEquals(null, $this->context->get('test'));
}
示例2: test_stack
public function test_stack()
{
$context = new Context();
$this->assertSame([], $context->to_array());
$context->push();
$context['one'] = 1;
$this->assertSame(['one' => 1], $context->to_array());
$context->push();
$context['two'] = 2;
$this->assertSame(['one' => 1, 'two' => 2], $context->to_array());
$context->push();
$context['three'] = 3;
$this->assertSame(['one' => 1, 'two' => 2, 'three' => 3], $context->to_array());
$context->pop();
$this->assertSame(['one' => 1, 'two' => 2], $context->to_array());
$context->pop();
$this->assertSame(['one' => 1], $context->to_array());
$context->pop();
$this->assertSame([], $context->to_array());
}
示例3: test_context
public function test_context()
{
$c = new Context(array('a' => 1, 'b' => 'xyzzy'));
$this->assertEquals($c['a'], 1);
$this->assertEquals($c->push(), array());
$c['a'] = 2;
$this->assertEquals($c['a'], 2);
$this->assertEquals($c->get('a'), 2);
$this->assertEquals($c->pop(), array('a' => 2));
$this->assertEquals($c['a'], 1);
$this->assertEquals($c->get('foo', 42), 42);
}
示例4: testContext
public function testContext()
{
$server = $this->getMockBuilder('Deployer\\Server\\ServerInterface')->disableOriginalConstructor()->getMock();
$env = $this->getMockBuilder('Deployer\\Server\\Environment')->disableOriginalConstructor()->getMock();
$input = $this->getMockBuilder('Symfony\\Component\\Console\\Input\\InputInterface')->disableOriginalConstructor()->getMock();
$output = $this->getMockBuilder('Symfony\\Component\\Console\\Output\\OutputInterface')->disableOriginalConstructor()->getMock();
$context = new Context($server, $env, $input, $output);
$this->assertInstanceOf('Deployer\\Server\\ServerInterface', $context->getServer());
$this->assertInstanceOf('Deployer\\Server\\Environment', $context->getEnvironment());
$this->assertInstanceOf('Symfony\\Component\\Console\\Input\\InputInterface', $context->getInput());
$this->assertInstanceOf('Symfony\\Component\\Console\\Output\\OutputInterface', $context->getOutput());
Context::push($context);
$this->assertEquals($context, Context::get());
$this->assertEquals($context, Context::pop());
}
示例5: run
/**
* Run task.
*
* @param Context $context
*/
public function run(Context $context)
{
Context::push($context);
$env = $context->getEnvironment();
// Save cd's working_path path.
if ($env !== null) {
$workingPath = $env->get('working_path', false);
}
// Call tasks.
call_user_func($this->callback);
// Restore cd's working_path path.
if ($env !== null && isset($workingPath)) {
$env->set('working_path', $workingPath);
}
Context::pop();
}
示例6: testContainsTellsYouIfAGivenContextIsInTheCurrentStack
public function testContainsTellsYouIfAGivenContextIsInTheCurrentStack()
{
$context = new Context();
$context->push('foo');
$context->push('bar');
$context->push('baz');
$this->assertTrue($context->contains('foo'));
$this->assertTrue($context->contains('bar'));
$this->assertTrue($context->contains('baz'));
$popped = $context->pop();
$this->assertFalse($context->contains($popped));
// TODO: remove once global state is fully deprecated (2.0)
_elgg_services()->setValue('context', new Context());
elgg_push_context('foo');
elgg_push_context('bar');
elgg_push_context('baz');
$this->assertTrue(elgg_in_context('foo'));
$this->assertTrue(elgg_in_context('bar'));
$this->assertTrue(elgg_in_context('baz'));
$popped = elgg_pop_context();
$this->assertFalse(elgg_in_context($popped));
}
示例7: testFailToSetEmptyContext
public function testFailToSetEmptyContext()
{
$context = new Context();
$context->set(" ");
$this->assertNull($context->peek());
$this->assertNull($context->pop());
$context->push(" ");
$this->assertEquals(" ", $context->peek());
$this->assertEquals(" ", $context->pop());
}