Phalcon\Test\Unit\Cache\Backend\RedisCest::output PHP Method

output() public method

public output ( UnitTester $I )
$I UnitTester
    public function output(UnitTester $I)
    {
        $I->wantTo('Cache output fragments by using Redis as cache backend');
        $time = date('H:i:s');
        $cache = new Redis(new Output(['lifetime' => 2]), ['host' => TEST_RS_HOST, 'port' => TEST_RS_PORT]);
        ob_start();
        // First time cache
        $content = $cache->start('test-output');
        $I->assertNull($content);
        echo $time;
        $cache->save(null, null, null, true);
        $obContent = ob_get_contents();
        ob_end_clean();
        $I->assertEquals($time, $obContent);
        $I->seeInRedis('_PHCR' . 'test-output', $time);
        // Expect same cache
        $content = $cache->start('test-output');
        $I->assertNotNull($content);
        $I->assertEquals($time, $obContent);
        $I->seeInRedis('_PHCR' . 'test-output', $time);
        sleep(2);
        $content = $cache->start('test-output');
        $I->assertNull($content);
        $I->dontSeeInRedis('_PHCR' . 'test-output');
    }