/codes-php/phpjakarta/tests/unit/WindowsAzure/ServiceBus/models/BrokeredMessageTest.php

http://bukuphpjs.codeplex.com · PHP · 513 lines · 225 code · 104 blank · 184 comment · 0 complexity · be5ed17af4cd4c6fe89c196862c7ea2f MD5 · raw file

  1. <?php
  2. /**
  3. * LICENSE: Licensed under the Apache License, Version 2.0 (the "License");
  4. * you may not use this file except in compliance with the License.
  5. * You may obtain a copy of the License at
  6. * http://www.apache.org/licenses/LICENSE-2.0
  7. *
  8. * Unless required by applicable law or agreed to in writing, software
  9. * distributed under the License is distributed on an "AS IS" BASIS,
  10. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. * See the License for the specific language governing permissions and
  12. * limitations under the License.
  13. *
  14. * PHP version 5
  15. *
  16. * @category Microsoft
  17. * @package Tests\Unit\WindowsAzure\ServiceBus\Models
  18. * @author Azure PHP SDK <azurephpsdk@microsoft.com>
  19. * @copyright 2012 Microsoft Corporation
  20. * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
  21. * @link https://github.com/WindowsAzure/azure-sdk-for-php
  22. */
  23. namespace Tests\Unit\WindowsAzure\ServiceBus\Models;
  24. use WindowsAzure\ServiceBus\Models\BrokeredMessage;
  25. use WindowsAzure\ServiceBus\Models\BrokerProperties;
  26. /**
  27. * Unit tests for class brokered message.
  28. *
  29. * @category Microsoft
  30. * @package Tests\Unit\WindowsAzure\ServiceBus\Models
  31. * @author Azure PHP SDK <azurephpsdk@microsoft.com>
  32. * @copyright 2012 Microsoft Corporation
  33. * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
  34. * @version Release: @package_version@
  35. * @link https://github.com/WindowsAzure/azure-sdk-for-php
  36. */
  37. class BrokeredMessageTest extends \PHPUnit_Framework_TestCase
  38. {
  39. /**
  40. * @covers WindowsAzure\ServiceBus\Models\BrokeredMessage::__construct
  41. */
  42. public function testBrokeredMessageConstructor()
  43. {
  44. // Setup
  45. $message = 'testMessage';
  46. // Test
  47. $brokeredMessage = new BrokeredMessage($message);
  48. // Assert
  49. $this->assertNotNull($brokeredMessage);
  50. }
  51. /**
  52. * @covers WindowsAzure\ServiceBus\Models\BrokeredMessage::getBrokerProperties
  53. */
  54. public function testBrokeredMessageConstructorWithMessage()
  55. {
  56. // Setup
  57. $expected = 'testMessage';
  58. // Test
  59. $brokeredMessage = new BrokeredMessage($expected);
  60. $actual = $brokeredMessage->getBody();
  61. // Assert
  62. $this->assertEquals(
  63. $expected,
  64. $actual
  65. );
  66. }
  67. /**
  68. * @covers WindowsAzure\ServiceBus\Models\BrokeredMessage::getBrokerProperties
  69. * @covers WindowsAzure\ServiceBus\Models\BrokeredMessage::setBrokerProperties
  70. */
  71. public function testGetSetBrokerProperties() {
  72. // Setup
  73. $expected = new BrokerProperties();
  74. $brokeredMessage = new BrokeredMessage();
  75. // Test
  76. $brokeredMessage->setBrokerProperties($expected);
  77. $actual = $brokeredMessage->getBrokerProperties();
  78. // Assert
  79. $this->assertEquals(
  80. $expected,
  81. $actual
  82. );
  83. }
  84. /**
  85. * @covers WindowsAzure\ServiceBus\Models\BrokeredMessage::getBody
  86. * @covers WindowsAzure\ServiceBus\Models\BrokeredMessage::setBody
  87. */
  88. public function testGetSetBody() {
  89. // Setup
  90. $expected = 'testBody';
  91. $brokeredMessage = new BrokeredMessage();
  92. // Test
  93. $brokeredMessage->setBody($expected);
  94. $actual = $brokeredMessage->getBody();
  95. // Assert
  96. $this->assertEquals(
  97. $expected,
  98. $actual
  99. );
  100. }
  101. /**
  102. * @covers WindowsAzure\ServiceBus\Models\BrokeredMessage::getContentType
  103. * @covers WindowsAzure\ServiceBus\Models\BrokeredMessage::setContentType
  104. */
  105. public function testGetSetContentType() {
  106. // Setup
  107. $expected = 'testContentType';
  108. $brokeredMessage = new BrokeredMessage();
  109. // Test
  110. $brokeredMessage->setContentType($expected);
  111. $actual = $brokeredMessage->getContentType();
  112. // Assert
  113. $this->assertEquals(
  114. $expected,
  115. $actual
  116. );
  117. }
  118. /**
  119. * @covers WindowsAzure\ServiceBus\Models\BrokeredMessage::getDate
  120. * @covers WindowsAzure\ServiceBus\Models\BrokeredMessage::setDate
  121. */
  122. public function testGetSetDate() {
  123. // Setup
  124. $expected = 'testDate';
  125. $brokeredMessage = new BrokeredMessage();
  126. // Test
  127. $brokeredMessage->setDate($expected);
  128. $actual = $brokeredMessage->getDate();
  129. // Assert
  130. $this->assertEquals(
  131. $expected,
  132. $actual
  133. );
  134. }
  135. /**
  136. * @covers WindowsAzure\ServiceBus\Models\BrokeredMessage::getProperties
  137. * @covers WindowsAzure\ServiceBus\Models\BrokeredMessage::setProperty
  138. */
  139. public function testGetSetCustomProperties() {
  140. // Setup
  141. $expected = 'testCustomPropertyValue';
  142. $testCustomPropertyKey = 'testCustomPropertyKey';
  143. $brokeredMessage = new BrokeredMessage();
  144. // Test
  145. $brokeredMessage->setProperty($testCustomPropertyKey, $expected);
  146. $customProperties = $brokeredMessage->getProperties();
  147. $actual = $customProperties[strtolower($testCustomPropertyKey)];
  148. // Assert
  149. $this->assertEquals(
  150. $expected,
  151. $actual
  152. );
  153. }
  154. /**
  155. * @covers WindowsAzure\ServiceBus\Models\BrokeredMessage::getCorrelationId
  156. * @covers WindowsAzure\ServiceBus\Models\BrokeredMessage::setCorrelationId
  157. */
  158. public function testGetSetCorrelationId() {
  159. // Setup
  160. $expected = 'testCorrelationId';
  161. $brokeredMessage = new BrokeredMessage();
  162. // Test
  163. $brokeredMessage->setCorrelationId($expected);
  164. $actual = $brokeredMessage->getCorrelationId();
  165. // Assert
  166. $this->assertEquals(
  167. $expected,
  168. $actual
  169. );
  170. }
  171. /**
  172. * @covers WindowsAzure\ServiceBus\Models\BrokeredMessage::getSessionId
  173. * @covers WindowsAzure\ServiceBus\Models\BrokeredMessage::setSessionId
  174. */
  175. public function testGetSetSessionId() {
  176. // Setup
  177. $expected = 'testSessionId';
  178. $brokeredMessage = new BrokeredMessage();
  179. // Test
  180. $brokeredMessage->setSessionId($expected);
  181. $actual = $brokeredMessage->getSessionId();
  182. // Assert
  183. $this->assertEquals(
  184. $expected,
  185. $actual
  186. );
  187. }
  188. /**
  189. * @covers WindowsAzure\ServiceBus\Models\BrokeredMessage::getDeliveryCount
  190. * @covers WindowsAzure\ServiceBus\Models\BrokeredMessage::setDeliveryCount
  191. */
  192. public function testGetSetDeliveryCount() {
  193. // Setup
  194. $expected = 100;
  195. $brokeredMessage = new BrokeredMessage();
  196. // Test
  197. $brokeredMessage->setDeliveryCount($expected);
  198. $actual = $brokeredMessage->getDeliveryCount();
  199. // Assert
  200. $this->assertEquals(
  201. $expected,
  202. $actual
  203. );
  204. }
  205. /**
  206. * @covers WindowsAzure\ServiceBus\Models\BrokeredMessage::getLockedUntilUtc
  207. * @covers WindowsAzure\ServiceBus\Models\BrokeredMessage::setLockedUntilUtc
  208. */
  209. public function testGetSetLockedUntilUtc() {
  210. // Setup
  211. $expected = 'testLockedUntilUtc';
  212. $brokeredMessage = new BrokeredMessage();
  213. // Test
  214. $brokeredMessage->setLockedUntilUtc($expected);
  215. $actual = $brokeredMessage->getLockedUntilUtc();
  216. // Assert
  217. $this->assertEquals(
  218. $expected,
  219. $actual
  220. );
  221. }
  222. /**
  223. * @covers WindowsAzure\ServiceBus\Models\BrokeredMessage::getLockToken
  224. * @covers WindowsAzure\ServiceBus\Models\BrokeredMessage::setLockToken
  225. */
  226. public function testGetSetLockToken() {
  227. // Setup
  228. $expected = 'testLockToken';
  229. $brokeredMessage = new BrokeredMessage();
  230. // Test
  231. $brokeredMessage->setLockToken($expected);
  232. $actual = $brokeredMessage->getLockToken();
  233. // Assert
  234. $this->assertEquals(
  235. $expected,
  236. $actual
  237. );
  238. }
  239. /**
  240. * @covers WindowsAzure\ServiceBus\Models\BrokeredMessage::getMessageId
  241. * @covers WindowsAzure\ServiceBus\Models\BrokeredMessage::setMessageId
  242. */
  243. public function testGetSetMessageId() {
  244. // Setup
  245. $expected = 'testMessageId';
  246. $brokeredMessage = new BrokeredMessage();
  247. // Test
  248. $brokeredMessage->setMessageId($expected);
  249. $actual = $brokeredMessage->getMessageId();
  250. // Assert
  251. $this->assertEquals(
  252. $expected,
  253. $actual
  254. );
  255. }
  256. /**
  257. * @covers WindowsAzure\ServiceBus\Models\BrokeredMessage::getLabel
  258. * @covers WindowsAzure\ServiceBus\Models\BrokeredMessage::setLabel
  259. */
  260. public function testGetSetLabel() {
  261. // Setup
  262. $expected = 'testLabel';
  263. $brokeredMessage = new BrokeredMessage();
  264. // Test
  265. $brokeredMessage->setLabel($expected);
  266. $actual = $brokeredMessage->getLabel();
  267. // Assert
  268. $this->assertEquals(
  269. $expected,
  270. $actual
  271. );
  272. }
  273. /**
  274. * @covers WindowsAzure\ServiceBus\Models\BrokeredMessage::getReplyTo
  275. * @covers WindowsAzure\ServiceBus\Models\BrokeredMessage::setReplyTo
  276. */
  277. public function testGetSetReplyTo() {
  278. // Setup
  279. $expected = 'testReplyTo';
  280. $brokeredMessage = new BrokeredMessage();
  281. // Test
  282. $brokeredMessage->setReplyTo($expected);
  283. $actual = $brokeredMessage->getReplyTo();
  284. // Assert
  285. $this->assertEquals(
  286. $expected,
  287. $actual
  288. );
  289. }
  290. /**
  291. * @covers WindowsAzure\ServiceBus\Models\BrokeredMessage::getSequenceNumber
  292. * @covers WindowsAzure\ServiceBus\Models\BrokeredMessage::setSequenceNumber
  293. */
  294. public function testGetSetSequenceNumber() {
  295. // Setup
  296. $expected = 58;
  297. $brokeredMessage = new BrokeredMessage();
  298. // Test
  299. $brokeredMessage->setSequenceNumber($expected);
  300. $actual = $brokeredMessage->getSequenceNumber();
  301. // Assert
  302. $this->assertEquals(
  303. $expected,
  304. $actual
  305. );
  306. }
  307. /**
  308. * @covers WindowsAzure\ServiceBus\Models\BrokeredMessage::getTimeToLive
  309. * @covers WindowsAzure\ServiceBus\Models\BrokeredMessage::setTimeToLive
  310. */
  311. public function testGetSetTimeToLive() {
  312. // Setup
  313. $expected = 'testTimeToLive';
  314. $brokeredMessage = new BrokeredMessage();
  315. // Test
  316. $brokeredMessage->setTimeToLive($expected);
  317. $actual = $brokeredMessage->getTimeToLive();
  318. // Assert
  319. $this->assertEquals(
  320. $expected,
  321. $actual
  322. );
  323. }
  324. /**
  325. * @covers WindowsAzure\ServiceBus\Models\BrokeredMessage::getTo
  326. * @covers WindowsAzure\ServiceBus\Models\BrokeredMessage::setTo
  327. */
  328. public function testGetSetTo() {
  329. // Setup
  330. $expected = 'testTo';
  331. $brokeredMessage = new BrokeredMessage();
  332. // Test
  333. $brokeredMessage->setTo($expected);
  334. $actual = $brokeredMessage->getTo();
  335. // Assert
  336. $this->assertEquals(
  337. $expected,
  338. $actual
  339. );
  340. }
  341. /**
  342. * @covers WindowsAzure\ServiceBus\Models\BrokeredMessage::getScheduledEnqueueTimeUtc
  343. * @covers WindowsAzure\ServiceBus\Models\BrokeredMessage::setScheduledEnqueueTimeUtc
  344. */
  345. public function testGetSetScheduledEnqueueTimeUtc() {
  346. // Setup
  347. $expected = 'testScheduledEnqueueTimeUtc';
  348. $brokeredMessage = new BrokeredMessage();
  349. // Test
  350. $brokeredMessage->setScheduledEnqueueTimeUtc($expected);
  351. $actual = $brokeredMessage->getScheduledEnqueueTimeUtc();
  352. // Assert
  353. $this->assertEquals(
  354. $expected,
  355. $actual
  356. );
  357. }
  358. /**
  359. * @covers WindowsAzure\ServiceBus\Models\BrokeredMessage::getReplyToSessionId
  360. * @covers WindowsAzure\ServiceBus\Models\BrokeredMessage::setReplyToSessionId
  361. */
  362. public function testGetSetReplyToSessionId() {
  363. // Setup
  364. $expected = 'testReplyToSessionId';
  365. $brokeredMessage = new BrokeredMessage();
  366. // Test
  367. $brokeredMessage->setReplyToSessionId($expected);
  368. $actual = $brokeredMessage->getReplyToSessionId();
  369. // Assert
  370. $this->assertEquals(
  371. $expected,
  372. $actual
  373. );
  374. }
  375. /**
  376. * @covers WindowsAzure\ServiceBus\Models\BrokeredMessage::getMessageLocation
  377. * @covers WindowsAzure\ServiceBus\Models\BrokeredMessage::setMessageLocation
  378. */
  379. public function testGetSetMessageLocation() {
  380. // Setup
  381. $expected = 'testMessageLocation';
  382. $brokeredMessage = new BrokeredMessage();
  383. // Test
  384. $brokeredMessage->setMessageLocation($expected);
  385. $actual = $brokeredMessage->getMessageLocation();
  386. // Assert
  387. $this->assertEquals(
  388. $expected,
  389. $actual
  390. );
  391. }
  392. /**
  393. * @covers WindowsAzure\ServiceBus\Models\BrokeredMessage::getLockLocation
  394. * @covers WindowsAzure\ServiceBus\Models\BrokeredMessage::setLockLocation
  395. */
  396. public function testGetSetLockLocation() {
  397. // Setup
  398. $expected = 'testLockLocation';
  399. $brokeredMessage = new BrokeredMessage();
  400. // Test
  401. $brokeredMessage->setLockLocation($expected);
  402. $actual = $brokeredMessage->getLockLocation();
  403. // Assert
  404. $this->assertEquals(
  405. $expected,
  406. $actual
  407. );
  408. }
  409. }