Example #1
0
	/**
	 * @covers Bedrock\View::__set
	 * @covers Bedrock\View::setValue
	 * @covers Bedrock\View::__get
	 * @covers Bedrock\View::getValue
	 *
	 * @return void
	 */
	public function test__setAnd__get() {
		// Setup
		$mockThree = new \stdClass();

		$this->_object->__set('one', 'unus');
		$this->_object->two = 'duo';
		$this->_object->three = $mockThree;

		// Assertions
		$this->assertAttributeCount((3 + 1), '_values', $this->_object); //PHPUnit adds __phpunit_mockObjectId, so count ends up being +1

		$this->assertAttributeContains('unus', '_values', $this->_object);
		$this->assertEquals('unus', $this->_object->__get('one'));
		$this->assertEquals('unus', $this->_object->one);
		$this->assertEquals('unus', $this->_object->getValue('one'));

		$this->assertAttributeContains('duo', '_values', $this->_object);
		$this->assertEquals('duo', $this->_object->__get('two'));
		$this->assertEquals('duo', $this->_object->two);
		$this->assertEquals('duo', $this->_object->getValue('two'));

		$this->assertAttributeContains($mockThree, '_values', $this->_object);
		$this->assertSame($mockThree, $this->_object->__get('three'));
		$this->assertSame($mockThree, $this->_object->three);
		$this->assertSame($mockThree, $this->_object->getValue('three'));
	}
 /**
  * Called when a request for a non-existant member variable is caught.
  * If the requested $variable matches a known helper we will attempt to
  * load it up for the caller.
  *
  * @param string $helperName name of helper to load
  * @return mixed
  */
 public function __get($helperName)
 {
     if (isset($this->_helpers[$helperName])) {
         return $this->Helpers->load($this->_helpers[$helperName]['class'], $this->_helpers[$helperName]['settings']);
     }
     return parent::__get($helperName);
 }