/** 
  * @covers WindowsAzure\ServiceBus\Models\SqlFilter::getCompatibilityLevel
  * @covers WindowsAzure\ServiceBus\Models\SqlFilter::setCompatibilityLevel
  */
 public function testGetSetCompatibilityLevel()
 {
     // Setup
     $expected = 'testCompatibilityLevel';
     $filter = new SqlFilter();
     // Test
     $filter->setCompatibilityLevel($expected);
     $actual = $filter->getCompatibilityLevel();
     // 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;
 }
 /**
  * With sql expression filter. 
  * 
  * @param string $sqlExpression The SQL expression of the filter. 
  * 
  * @return none
  */
 public function withSqlFilter($sqlExpression)
 {
     $filter = new SqlFilter();
     $filter->setSqlExpression($sqlExpression);
     $filter->setCompatibilityLevel(20);
     $this->_ruleDescription->setFilter($filter);
 }