当前位置: 首页>>代码示例>>PHP>>正文


PHP Context::pop方法代码示例

本文整理汇总了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'));
 }
开发者ID:QuentinBellus,项目名称:php-liquid,代码行数:8,代码来源:ContextTest.php

示例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());
 }
开发者ID:icybee,项目名称:bluetihi,代码行数:20,代码来源:ContextTest.php

示例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);
 }
开发者ID:idlesign,项目名称:dja,代码行数:12,代码来源:context.php

示例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());
 }
开发者ID:acorncom,项目名称:deployer,代码行数:15,代码来源:ContextTest.php

示例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();
 }
开发者ID:acorncom,项目名称:deployer,代码行数:21,代码来源:Task.php

示例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));
 }
开发者ID:sephiroth88,项目名称:Elgg,代码行数:22,代码来源:ContextTest.php

示例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());
 }
开发者ID:ibou77,项目名称:elgg,代码行数:10,代码来源:ContextTest.php


注:本文中的Context::pop方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。