validator = new CEventNameValidator(); } /** * An array of e-mails, results and error messages. */ public function dataProvider() { return [ ['', true, null], ['Macro except expression macro are ignored {ANY_MACRO_HERE}', true, null], ['Incorrect macro except expression macro are ignored {ANY_MACRO_HERE_ {}', true, null], ['Simple expression macro {?100+1} test', true, null], ['Expression macro with modificator {{?100+1-(2)}.anyfunc(2)}', true, null], ['Macro as host name {?func(/{HOST.HOST}/item)}', true, null], ['Expression macro with incorrect syntax {?123++321}', false, 'incorrect expression starting from "+321}"'], ['Missing closing curly bracket {?123+321', false, 'unexpected end of expression macro'], ['{?Expression macro without closing bracket', false, 'incorrect expression starting from "Expression macro without closing bracket"'], ['Expression macro without closing bracket at the end of event name {?', false, 'incorrect expression starting from ""'], ['Nested expression macro not supported {?100+{?20+1}}', false, 'incorrect expression starting from "{?20+1}}"'], ['Empty expression macro {?}', false, 'incorrect expression starting from "}"'] ]; } /** * @dataProvider dataProvider */ public function testValidateEmail($event_name, $expected, $error) { $this->assertSame($this->validator->validate($event_name), $expected); $this->assertSame($error, $this->validator->getError()); } }