public function testContext() { $test = new stdClass(); $test->value = 'value'; $test->array = array('a' => '1', 'b' => '2', '!"#%&\'()*+,./;<=>@[\\^`{|}~ ' => '3'); $context = new \Handlebars\Context($test); $this->assertEquals('value', $context->get('value')); $this->assertEquals('value', $context->get('value', true)); $this->assertEquals('value', $context->get('[value]', true)); $this->assertEquals('1', $context->get('array.a', true)); $this->assertEquals('2', $context->get('array.b', true)); $this->assertEquals('3', $context->get('array.[!"#%&\'()*+,./;<=>@[\\^`{|}~ ]', true)); $new = array('value' => 'new value'); $context->push($new); $this->assertEquals('new value', $context->get('value')); $this->assertEquals('new value', $context->get('value', true)); $this->assertEquals('value', $context->get('../value')); $this->assertEquals('value', $context->get('../value', true)); $this->assertEquals($new, $context->last()); $this->assertEquals($new, $context->get('.')); $this->assertEquals($new, $context->get('this')); $this->assertEquals($new, $context->get('this.')); $this->assertEquals($test, $context->get('../.')); $context->pop(); $this->assertEquals('value', $context->get('value')); $this->assertEquals('value', $context->get('value', true)); }
public function testContext() { $test = new stdClass(); $test->value = 'value'; $test->array = array('a' => '1', 'b' => '2'); $context = new \Handlebars\Context($test); $this->assertEquals('value', $context->get('value')); $this->assertEquals('value', $context->get('value', true)); $this->assertEquals('1', $context->get('array.a', true)); $this->assertEquals('2', $context->get('array.b', true)); $new = array('value' => 'new value'); $context->push($new); $this->assertEquals('new value', $context->get('value')); $this->assertEquals('new value', $context->get('value', true)); $this->assertEquals('value', $context->get('../value')); $this->assertEquals('value', $context->get('../value', true)); $this->assertEquals($new, $context->last()); $this->assertEquals($new, $context->get('.')); $this->assertEquals($new, $context->get('this')); $this->assertEquals($new, $context->get('this.')); $this->assertEquals($test, $context->get('../.')); $context->pop(); $this->assertEquals('value', $context->get('value')); $this->assertEquals('value', $context->get('value', true)); $this->assertFalse($context->lastIndex()); }