/** * With SQL rule action. * * @param string $sqlExpression The SQL expression * of the rule action. * * @return none */ public function withSqlRuleAction($sqlExpression) { $action = new SqlRuleAction(); $action->setCompatibilityLevel(20); $action->setSqlExpression($sqlExpression); $this->_ruleDescription->setAction($action); }
/** * @covers WindowsAzure\ServiceBus\Models\RuleDescription::getAction * @covers WindowsAzure\ServiceBus\Models\RuleDescription::setAction */ public function testGetSetAction() { // Setup $expected = 'testAction'; $ruleDescription = new RuleDescription(); // Test $ruleDescription->setAction($expected); $actual = $ruleDescription->getAction(); // Assert $this->assertEquals($expected, $actual); }
/** * Creates a rule description instance with specified XML string. * * @param string $ruleDescriptionXml A XML string representing the * rule description. * * @return none */ public static function create($ruleDescriptionXml) { $ruleDescription = new RuleDescription(); $root = simplexml_load_string($ruleDescriptionXml); $nameSpaces = $root->getNameSpaces(); $ruleDescriptionArray = (array) $root; if (array_key_exists('Filter', $ruleDescriptionArray)) { $filterItem = $ruleDescriptionArray['Filter']; $filterAttributes = $filterItem->attributes('i', true); $filterItemArray = (array) $filterItem; $filterType = (string) $filterAttributes['type']; $filter = null; switch ($filterType) { case 'TrueFilter': $filter = new TrueFilter(); break; case 'FalseFilter': $filter = new FalseFilter(); break; case 'CorrelationFilter': $filter = new CorrelationFilter(); if (array_key_exists('CorrelationId', $filterItemArray)) { $filter->setCorrelationId((string) $filterItemArray['CorrelationId']); } break; case 'SqlFilter': $filter = new SqlFilter(); if (array_key_exists('SqlExpression', $filterItemArray)) { $filter->setSqlExpression((string) $filterItemArray['SqlExpression']); } break; default: $filter = new Filter(); } if (array_key_exists('CompatibilityLevel', $filterItemArray)) { $filter->setCompatibilityLevel((int) $filterItemArray['CompatibilityLevel']); } $ruleDescription->setFilter($filter); } if (array_key_exists('Action', $ruleDescriptionArray)) { $actionItem = $ruleDescriptionArray['Action']; $actionAttributes = $actionItem->attributes('i', true); $actionType = (string) $actionAttributes['type']; $action = null; switch ($actionType) { case 'EmptyRuleAction': $action = new EmptyRuleAction(); break; case 'SqlRuleAction': $action = new SqlRuleAction(); if (array_key_exists('SqlExpression', $actionItem)) { $action->setSqlExpression((string) $actionItem['SqlExpression']); } break; default: $action = new Action(); } $ruleDescription->setAction($action); } if (array_key_exists('Name', $ruleDescriptionArray)) { $ruleDescription->setName((string) $ruleDescriptionArray['Name']); } return $ruleDescription; }