/** * @covers WindowsAzure\ServiceBus\Models\RuleInfo::__construct */ public function testRuleInfoConstructor() { // Setup $expected = 'testRuleInfoName'; // Test $ruleInfo = new RuleInfo($expected); $actual = $ruleInfo->getTitle(); // Assert $this->assertNotNull($ruleInfo); $this->assertEquals($expected, $actual); }
/** * Creates a rule. * * @link http://msdn.microsoft.com/en-us/library/windowsazure/hh780774 * * @param string $topicPath The path of the topic. * @param string $subscriptionName The name of the subscription. * @param RuleInfo $ruleInfo The information of the rule. * * @return RuleInfo */ public function createRule($topicPath, $subscriptionName, $ruleInfo) { $httpCallContext = new HttpCallContext(); $httpCallContext->setMethod(Resources::HTTP_PUT); $httpCallContext->addStatusCode(Resources::STATUS_CREATED); $httpCallContext->addHeader(Resources::CONTENT_TYPE, Resources::ATOM_ENTRY_CONTENT_TYPE); $rulePath = sprintf(Resources::RULE_PATH, $topicPath, $subscriptionName, $ruleInfo->getTitle()); $ruleDescriptionXml = XmlSerializer::objectSerialize($ruleInfo->getRuleDescription(), 'RuleDescription'); $entry = new Entry(); $content = new Content($ruleDescriptionXml); $content->setType(Resources::XML_CONTENT_TYPE); $entry->setContent($content); $entry->setAttribute(Resources::XMLNS, Resources::SERVICE_BUS_NAMESPACE); $xmlWriter = new \XMLWriter(); $xmlWriter->openMemory(); $entry->writeXml($xmlWriter); $httpCallContext->setBody($xmlWriter->outputMemory()); $httpCallContext->setPath($rulePath); $response = $this->sendContext($httpCallContext); $ruleInfo = new ruleInfo(); $ruleInfo->parseXml($response->getBody()); return $ruleInfo; }