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'));
	}