コード例 #1
0
 /**
  * Generate cache filename
  *
  * @return string md5
  */
 public function strategy()
 {
     //when session support is enabled add that to file name
     $session_str = SessionHandler::process();
     $uri = empty($_SERVER['REQUEST_URI']) ? '' : $_SERVER['REQUEST_URI'];
     $query = empty($_SERVER['QUERY_STRING']) ? '' : $_SERVER['QUERY_STRING'];
     return md5($uri . $_SERVER['SCRIPT_NAME'] . $query . $session_str);
 }
コード例 #2
0
 public function testExceptionArray()
 {
     try {
         SessionHandler::excludeKeys('stringvalue is not scalar array');
         $this->expectException('PHPUnit_Framework_Error');
     } catch (\Throwable $e) {
         // echo '~~~~As expected PHP7 throws Throwable.';
     } catch (\Exception $e) {
         // echo '~~~~As expected PHP5 throws Exception.';
     }
 }
コード例 #3
0
 /**
  * Generate cache file name
  * Sets a "-mob" ending to cache files for visitors coming from mobile devices (phones but not tablets)
  *
  * @return string file name
  */
 public function strategy()
 {
     $ends = '';
     if ($this->currentMobile()) {
         $ends = '-mob';
     }
     //when session support is enabled add that to file name
     $session_str = SessionHandler::process();
     $uri = empty($_SERVER['REQUEST_URI']) ? '' : $_SERVER['REQUEST_URI'];
     $query = empty($_SERVER['QUERY_STRING']) ? '' : $_SERVER['QUERY_STRING'];
     return md5($uri . $_SERVER['SCRIPT_NAME'] . $query . $session_str) . $ends;
 }
コード例 #4
0
 public function testStrategy()
 {
     $strategy = new DefaultStrategy();
     $this->assertTrue($strategy instanceof StrategyInterface);
     SessionHandler::disable();
     $uri = empty($_SERVER['REQUEST_URI']) ? '' : $_SERVER['REQUEST_URI'];
     $query = empty($_SERVER['QUERY_STRING']) ? '' : $_SERVER['QUERY_STRING'];
     $md5 = md5($uri . $_SERVER['SCRIPT_NAME'] . $query);
     $this->assertEquals($md5, $strategy->strategy());
     SessionHandler::enable();
     $this->assertNotEmpty($strategy->strategy());
 }
コード例 #5
0
 public function testStrategy()
 {
     //MobileDetection stub, to simulate a mobile device
     $mobilestub = $this->getMockBuilder('Mobile_Detect')->setMethods(array('isMobile', 'isTablet'))->getMock();
     $mobilestub->method('isMobile')->willReturn(true);
     $mobilestub->method('isTablet')->willReturn(false);
     $strategy = new MobileStrategy($mobilestub);
     //expected string, with -mob in the end
     SessionHandler::disable();
     $uri = empty($_SERVER['REQUEST_URI']) ? '' : $_SERVER['REQUEST_URI'];
     $query = empty($_SERVER['QUERY_STRING']) ? '' : $_SERVER['QUERY_STRING'];
     $md5 = md5($uri . $_SERVER['SCRIPT_NAME'] . $query) . '-mob';
     $this->assertTrue($mobilestub instanceof \Mobile_Detect);
     $this->assertTrue($strategy instanceof StrategyInterface);
     $this->assertEquals($md5, $strategy->strategy());
 }
コード例 #6
0
ファイル: PageCache.php プロジェクト: mmamedov/page-cache
 /**
  * Destroy PageCache instance
  */
 public static function destroy()
 {
     if (isset(PageCache::$ins)) {
         PageCache::$ins = null;
         SessionHandler::reset();
     }
 }
コード例 #7
0
ファイル: PageCacheTest.php プロジェクト: mmamedov/page-cache
 public function testDestroy()
 {
     $pc = new PageCache();
     $pc->enableSession();
     $this->assertEquals(true, SessionHandler::getStatus());
     $pc->destroy();
     $pc2 = new PageCache();
     $this->assertEquals(false, SessionHandler::getStatus());
 }