/** * Test for adding rule * * @param array $rule Rule to test * @param array $expected Expected rendered rule in fired/errors list * @param string $error Expected error string (null if none error expected) * * @return void * * @depends testParse * @dataProvider rulesProvider */ public function testAddRule($rule, $expected, $error) { $advisor = new Advisor(); $parseResult = $advisor->parseRulesFile(); $this->assertEquals($parseResult['errors'], array()); $advisor->setVariable('value', 0); $advisor->addRule('fired', $rule); $runResult = $advisor->getRunResult(); if (isset($runResult['errors']) || !is_null($error)) { $this->assertEquals(array($error), $runResult['errors']); } if (isset($runResult['fired']) || $expected != array()) { $this->assertEquals(array($expected), $runResult['fired']); } }