From 06f945f27840b53e57795dadbc38e76f7e11ab1c Mon Sep 17 00:00:00 2001 From: Horus3 Date: Mon, 24 Feb 2014 16:42:14 +0100 Subject: init --- zend/tests/Zend/Gdata/Analytics/DataQueryTest.php | 101 ++++++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 zend/tests/Zend/Gdata/Analytics/DataQueryTest.php (limited to 'zend/tests/Zend/Gdata/Analytics/DataQueryTest.php') diff --git a/zend/tests/Zend/Gdata/Analytics/DataQueryTest.php b/zend/tests/Zend/Gdata/Analytics/DataQueryTest.php new file mode 100644 index 0000000..f3d4653 --- /dev/null +++ b/zend/tests/Zend/Gdata/Analytics/DataQueryTest.php @@ -0,0 +1,101 @@ +dataQuery = new Zend_GData_Analytics_DataQuery(); + } + + public function testProfileId() + { + $this->assertTrue($this->dataQuery->getProfileId() == null); + $this->dataQuery->setProfileId(123456); + $this->assertTrue($this->dataQuery->getProfileId() == 123456); + } + + public function testAddMetric() + { + $this->assertTrue(count($this->dataQuery->getMetrics()) == 0); + $this->dataQuery->addMetric(Zend_GData_Analytics_DataQuery::METRIC_BOUNCES); + $this->assertTrue(count($this->dataQuery->getMetrics()) == 1); + } + + public function testAddAndRemoveMetric() + { + $this->dataQuery->addMetric(Zend_GData_Analytics_DataQuery::METRIC_BOUNCES); + $this->dataQuery->removeMetric(Zend_GData_Analytics_DataQuery::METRIC_BOUNCES); + $this->assertTrue(count($this->dataQuery->getMetrics()) == 0); + } + + public function testAddDimension() + { + $this->assertTrue(count($this->dataQuery->getDimensions()) == 0); + $this->dataQuery->addDimension(Zend_GData_Analytics_DataQuery::DIMENSION_AD_SLOT); + $this->assertTrue(count($this->dataQuery->getDimensions()) == 1); + } + + public function testAddAndRemoveDimension() + { + $this->dataQuery->addDimension(Zend_GData_Analytics_DataQuery::DIMENSION_AD_SLOT); + $this->dataQuery->removeDimension(Zend_GData_Analytics_DataQuery::DIMENSION_AD_SLOT); + $this->assertTrue(count($this->dataQuery->getDimensions()) == 0); + } + + public function testQueryString() + { + $this->dataQuery + ->setProfileId(123456789) + ->addFilter('foo=bar') + ->addFilter('bar>2') + ->addOrFilter('baz=42') + ->addDimension(Zend_GData_Analytics_DataQuery::DIMENSION_CITY) + ->addMetric(Zend_GData_Analytics_DataQuery::METRIC_PAGEVIEWS) + ->addMetric(Zend_GData_Analytics_DataQuery::METRIC_VISITS); + $url = parse_url($this->dataQuery->getQueryUrl()); + parse_str($url['query'], $parameter); + + $this->assertEquals(count($parameter), 4); + $this->assertEquals($parameter['ids'], "ga:123456789"); + $this->assertEquals($parameter['dimensions'], "ga:city"); + $this->assertEquals($parameter['metrics'], "ga:pageviews,ga:visits"); + $this->assertEquals($parameter['filters'], 'foo=bar;bar>2,baz=42'); + } +} -- cgit v1.2.3