Пример #1
0
 public function testFind()
 {
     $context = new Mustache_Context();
     $dummy = new Mustache_Test_TestDummy();
     $obj = new StdClass();
     $obj->name = 'obj';
     $arr = array('a' => array('b' => array('c' => 'see')), 'b' => 'bee');
     $string = 'some arbitrary string';
     $context->push($dummy);
     $this->assertEquals('dummy', $context->find('name'));
     $context->push($obj);
     $this->assertEquals('obj', $context->find('name'));
     $context->pop();
     $this->assertEquals('dummy', $context->find('name'));
     $dummy->name = 'dummyer';
     $this->assertEquals('dummyer', $context->find('name'));
     $context->push($arr);
     $this->assertEquals('bee', $context->find('b'));
     $this->assertEquals('see', $context->findDot('a.b.c'));
     $dummy->name = 'dummy';
     $context->push($string);
     $this->assertSame($string, $context->last());
     $this->assertEquals('dummy', $context->find('name'));
     $this->assertEquals('see', $context->findDot('a.b.c'));
     $this->assertEquals('<foo>', $context->find('foo'));
     $this->assertEquals('<bar>', $context->findDot('bar'));
 }
Пример #2
0
 protected function prepareContextStack($context = null)
 {
     $stack = new Mustache_Context();
     $helpers = $this->mustache->getHelpers();
     if (!$helpers->isEmpty()) {
         $stack->push($helpers);
     }
     if (!empty($context)) {
         $stack->push($context);
     }
     return $stack;
 }
Пример #3
0
 /**
  * @expectedException Mustache_Exception_InvalidArgumentException
  */
 public function testAnchoredDotNotationThrowsExceptions()
 {
     $context = new Mustache_Context();
     $context->push(array('a' => 1));
     $context->findAnchoredDot('a');
 }