tests/ModuleTest.php
/**
     * Test to ensure toolbar is never cached
     */
Test to ensure toolbar is never cached
Test to ensure toolbar is never cached
public function testNonCachedToolbarHtml()
    {
        $module = new Module('debug');
        $module->allowedIPs = ['*'];
        Yii::$app->setModule('debug', $module);
        $module->bootstrap(Yii::$app);
        Yii::getLogger()->dispatcher = $this->getMockBuilder('yii\\log\\Dispatcher')
            ->setMethods(['dispatch'])
            ->getMock();
        Yii::$app->set('cache', new FileCache(['cachePath' => '@yiiunit/debug/runtime/cache']));
        $view = Yii::$app->view;
        for ($i = 0; $i <= 1; $i++) {
            ob_start();
            $module->logTarget->tag = 'tag' . $i;
            if ($view->beginCache(__FUNCTION__, ['duration' => 3])) {
                $module->renderToolbar(new Event(['sender' => $view]));
                $view->endCache();
            }
            $output[$i] = ob_get_clean();
        }
        $this->assertNotEquals($output[0], $output[1]);
    }
public function testNonCachedToolbarHtml ( ) { $ module = new Module ( 'debug' ) ; $ module -> allowedIPs = [ '*' ] ; Yii :: $ app -> setModule ( 'debug' , $ module ) ; $ module -> bootstrap ( Yii :: $ app ) ; Yii :: getLogger ( ) -> dispatcher = $ this -> getMockBuilder ( 'yii\\log\\Dispatcher' ) -> setMethods ( [ 'dispatch' ] ) -> getMock ( ) ; Yii :: $ app -> set ( 'cache' , new FileCache ( [ 'cachePath' => '@yiiunit/debug/runtime/cache' ] ) ) ; $ view = Yii :: $ app -> view ; for ( $ i = 0 ; $ i <= 1 ; $ i ++ ) { ob_start ( ) ; $ module -> logTarget -> tag = 'tag' . $ i ; if ( $ view -> beginCache ( __FUNCTION__ , [ 'duration' => 3 ] ) ) { $ module -> renderToolbar ( new Event ( [ 'sender' => $ view ] ) ) ; $ view -> endCache ( ) ; } $ output [ $ i ] = ob_get_clean ( ) ; } $ this -> assertNotEquals ( $ output [ 0 ] , $ output [ 1 ] ) ; }
Test to ensure toolbar is never cached
Test to ensure toolbar is never cached