PageRenderTime 72ms CodeModel.GetById 6ms RepoModel.GetById 0ms app.codeStats 0ms

/codes-php/phpjakarta/tests/unit/WindowsAzure/Table/Models/QueryTest.php

http://bukuphpjs.codeplex.com
PHP | 113 lines | 37 code | 16 blank | 60 comment | 0 complexity | 16dfa408f2e4e5043902ece82f078bd1 MD5 | raw file
Possible License(s): Apache-2.0, MIT, LGPL-2.1
  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\Table\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\Table\Models;
  24. use WindowsAzure\Table\Models\Query;
  25. use WindowsAzure\Table\Models\Filters\Filter;
  26. use WindowsAzure\Table\Models\EdmType;
  27. /**
  28. * Unit tests for class Query
  29. *
  30. * @category Microsoft
  31. * @package Tests\Unit\WindowsAzure\Table\Models
  32. * @author Azure PHP SDK <azurephpsdk@microsoft.com>
  33. * @copyright 2012 Microsoft Corporation
  34. * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
  35. * @version Release: @package_version@
  36. * @link https://github.com/windowsazure/azure-sdk-for-php
  37. */
  38. class QueryTest extends \PHPUnit_Framework_TestCase
  39. {
  40. /**
  41. * @covers WindowsAzure\Table\Models\Query::setSelectFields
  42. * @covers WindowsAzure\Table\Models\Query::getSelectFields
  43. */
  44. public function testSetSelectFields()
  45. {
  46. // Setup
  47. $query = new Query();
  48. $expected = array('customerId', 'customerName');
  49. // Test
  50. $query->setSelectFields($expected);
  51. // Assert
  52. $this->assertEquals($expected, $query->getSelectFields());
  53. }
  54. /**
  55. * @covers WindowsAzure\Table\Models\Query::setTop
  56. * @covers WindowsAzure\Table\Models\Query::getTop
  57. */
  58. public function testSetTop()
  59. {
  60. // Setup
  61. $query = new Query();
  62. $expected = 123;
  63. // Test
  64. $query->setTop($expected);
  65. // Assert
  66. $this->assertEquals($expected, $query->getTop());
  67. }
  68. /**
  69. * @covers WindowsAzure\Table\Models\Query::setFilter
  70. * @covers WindowsAzure\Table\Models\Query::getFilter
  71. */
  72. public function testSetFilter()
  73. {
  74. // Setup
  75. $query = new Query();
  76. $expected = Filter::applyConstant('constValue', EdmType::STRING);
  77. // Test
  78. $query->setFilter($expected);
  79. // Assert
  80. $this->assertEquals($expected, $query->getFilter());
  81. }
  82. /**
  83. * @covers WindowsAzure\Table\Models\Query::addSelectField
  84. * @covers WindowsAzure\Table\Models\Query::getSelectFields
  85. */
  86. public function testAddSelectField()
  87. {
  88. // Setup
  89. $query = new Query();
  90. $field = 'customerId';
  91. $expected = array($field);
  92. // Test
  93. $query->addSelectField($field);
  94. // Assert
  95. $this->assertEquals($expected, $query->getSelectFields());
  96. }
  97. }