/** * @group Slow * @slowExecutionTime 0.09943 ms * @covers Wikia\Search\Result::setVar * @covers Wikia\Search\Result::getVar * @covers Wikia\Search\Result::getVars */ public function testVarMethods() { $result = new Result($this->defaultFields); $this->assertEquals($this->defaultFields, $result->getVars(), 'Wikia\\Search\\Result::getVars should return the protected $_fields array.'); $this->assertEquals($this->defaultFields['wid'], $result->getVar('wid'), 'Wikia\\Search\\Result::getVar should return any values already set in the result fields.'); $this->assertNull($result->getVar('NonExistentField'), 'Querying for nonexistent fields without a second parameter passed should return null in Wikia\\Search\\Result::getVar.'); $this->assertEquals('TestDefault', $result->getVar('NonExistentField', 'TestDefault'), 'Wikia\\Search\\Result::getVar should accommodate a flexible default value as the second parameter.'); $this->assertEquals($result, $result->setVar('foo', 'bar'), 'Wikia\\Search\\Result::setVar should provide a fluent interface.'); $this->assertEquals($result['foo'], $result->getVar('foo'), 'Wikia\\Search\\Result::setVar should store a value as a field, accessible by array methods or getVar().'); }