/** * Tests if the getAnalytic() method works as expected. * * @return void */ public function testGetAnalytic() { // create an AnalyticNode instance $analytic = new AnalyticNode(); $analytic->initFromFile(__DIR__ . '/_files/analytic.xml'); // mock the trait to be tested $mockTrait = $this->getMockForTrait('AppserverIo\\Appserver\\Core\\Api\\Node\\AnalyticsNodeTrait', array(), '', false, false, true, array('getAnalytics')); $mockTrait->expects($this->once())->method('getAnalytics')->will($this->returnValue(array($analytic))); // check the result $this->assertSame($analytic, $mockTrait->getAnalytic('^\\/welcome-page\\/logo_(.+?)_(.+?)_(.+?)\\.png.*')); }
/** * Tests if the getUri() method works as expected. * * @return void */ public function testGetType() { // initialize the analytic node $this->analytic->setNodeName('access'); $this->analytic->initFromFile(__DIR__ . '/_files/analytic.xml'); // initialize the array with result $connectors = array(array('name' => 'ga-app-tracking', 'type' => '\\AppserverIo\\WebServer\\Modules\\Analytics\\Connectors\\UniversalAnalytics\\MeasurementProtocol', 'params' => array('t' => 'screenview', 'av' => '$1', 'aid' => '$2', 'aiid' => '$3', 'tid' => 'UA-12386171-4', 'an' => 'appserver', 'cd' => 'installation'))); // check the URI and the connector configuration $this->assertSame('^\\/welcome-page\\/logo_(.+?)_(.+?)_(.+?)\\.png.*', $this->analytic->getUri()); $this->assertSame($connectors, $this->analytic->getConnectorsAsArray()); }