AccountQueryTest.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <?php
  2. /**
  3. * Zend Framework
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the new BSD license that is bundled
  8. * with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://framework.zend.com/license/new-bsd
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@zend.com so we can send you a copy immediately.
  14. *
  15. * @category Zend
  16. * @package Zend_Gdata_Analytics
  17. * @subpackage UnitTests
  18. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. * @version $Id$
  21. */
  22. require_once 'Zend/Gdata/Analytics.php';
  23. /**
  24. * @category Zend
  25. * @package Zend_Gdata_Analytics
  26. * @subpackage UnitTests
  27. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  28. * @license http://framework.zend.com/license/new-bsd New BSD License
  29. * @group Zend_Gdata
  30. * @group Zend_Gdata_Analytics
  31. */
  32. class Zend_GData_Analytics_AccountQueryTest extends PHPUnit_Framework_TestCase
  33. {
  34. /**
  35. * @var Zend_GData_Analytics_AccountQuery
  36. */
  37. public $accountQuery;
  38. public function setUp()
  39. {
  40. $this->accountQuery = new Zend_GData_Analytics_AccountQuery();
  41. $this->queryBase = Zend_GData_Analytics_AccountQuery::ANALYTICS_FEED_URI;
  42. }
  43. public function testWebpropertiesAll()
  44. {
  45. $this->accountQuery->webproperties();
  46. $allQuery = $this->accountQuery->getQueryUrl();
  47. $this->assertEquals(
  48. $this->queryBase . '/~all/webproperties',
  49. $allQuery
  50. );
  51. }
  52. public function testWebpropertiesSpecific()
  53. {
  54. $this->accountQuery->webproperties(12345678);
  55. $specificQuery = $this->accountQuery->getQueryUrl();
  56. $this->assertEquals(
  57. $this->queryBase . '/12345678/webproperties',
  58. $specificQuery
  59. );
  60. }
  61. public function testProfilesAll()
  62. {
  63. $this->accountQuery->profiles();
  64. $allQuery = $this->accountQuery->getQueryUrl();
  65. $this->assertEquals(
  66. $this->queryBase . '/~all/webproperties/~all/profiles',
  67. $allQuery
  68. );
  69. }
  70. public function testProfilesSpecific()
  71. {
  72. $this->accountQuery->profiles('U-87654321-0', 87654321);
  73. $specificQuery = $this->accountQuery->getQueryUrl();
  74. $this->assertEquals(
  75. $this->queryBase . '/87654321/webproperties/U-87654321-0/profiles',
  76. $specificQuery
  77. );
  78. }
  79. public function testGoalsAll()
  80. {
  81. $this->accountQuery->goals();
  82. $allQuery = $this->accountQuery->getQueryUrl();
  83. $this->assertEquals(
  84. $this->queryBase . '/~all/webproperties/~all/profiles/~all/goals',
  85. $allQuery
  86. );
  87. }
  88. public function testGoalsSpecific()
  89. {
  90. $this->accountQuery->goals(42, 'U-87654321-0', 87654321);
  91. $specificQuery = $this->accountQuery->getQueryUrl();
  92. $this->assertEquals(
  93. $this->queryBase . '/87654321/webproperties/U-87654321-0/profiles/42/goals',
  94. $specificQuery
  95. );
  96. }
  97. public function testChainedProperties()
  98. {
  99. $this->accountQuery
  100. ->goals(42)
  101. ->profiles('U-87654321-0')
  102. ->webproperties(87654321);
  103. $specificQuery = $this->accountQuery->getQueryUrl();
  104. $this->assertEquals(
  105. $this->queryBase . '/87654321/webproperties/U-87654321-0/profiles/42/goals',
  106. $specificQuery
  107. );
  108. }
  109. }