Exemplo n.º 1
0
 public function testLoadPageRedirectLanguage()
 {
     $site = CM_Site_Abstract::factory();
     CMTest_TH::createLanguage('en');
     $viewer = CMTest_TH::createUser();
     $environment = new CM_Frontend_Environment(null, $viewer);
     $component = new CM_Page_View_Ajax_Test_Mock();
     $response = $this->getResponseAjax($component, 'loadPage', ['path' => '/en' . CM_Page_View_Ajax_Test_Mock::getPath()], $environment);
     $this->assertViewResponseSuccess($response);
     $responseDecoded = CM_Params::jsonDecode($response->getContent());
     $this->assertSame($site->getUrl() . CM_Page_View_Ajax_Test_Mock::getPath(), $responseDecoded['success']['data']['url']);
 }
Exemplo n.º 2
0
 public function testLoadPageTrackingError()
 {
     CM_Config::get()->CM_Http_Response_Page->exceptionsToCatch['CM_Exception_Nonexistent'] = ['errorPage' => 'CM_Page_View_Ajax_Test_Mock'];
     $site = CM_Site_Abstract::factory();
     $page = new CM_Page_View_Ajax_Test_Mock();
     $env = new CM_Frontend_Environment($site, CMTest_TH::createUser());
     $params = ['path' => '/iwhdfkjlsh', 'currentLayout' => $page->getLayout($env)];
     $request = $this->createRequestAjax($page, 'loadPage', $params);
     $response = CM_Http_Response_View_Ajax::createFromRequest($request, $site, $this->_getServiceManagerWithGA('ga123'));
     $response->process();
     $this->assertViewResponseSuccess($response);
     $responseContent = CM_Params::decode($response->getContent(), true);
     $jsTracking = $responseContent['success']['data']['jsTracking'];
     $html = $responseContent['success']['data']['pageRendering']['html'];
     $this->assertSame(1, substr_count($jsTracking, 'ga("send", "pageview"'));
     $this->assertContains('ga("send", "pageview", "\\/iwhdfkjlsh")', $jsTracking);
     $this->assertContains('CM_Page_View_Ajax_Test_Mock', $html);
 }