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

output() public method

public output ( UnitTester $I )
$I UnitTester
    public function output(UnitTester $I)
    {
        $I->wantTo('Cache output fragments by using Memcache as cache backend');
        $time = date('H:i:s');
        $cache = new Memcache(new Output(['lifetime' => 2]), ['host' => TEST_MC_HOST, 'port' => TEST_MC_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->seeInMemcached('test-output', $time);
        // Expect same cache
        $content = $cache->start('test-output');
        $I->assertNotNull($content);
        $I->assertEquals($time, $obContent);
        $I->seeInMemcached('test-output', $time);
        sleep(2);
        $content = $cache->start('test-output');
        $I->assertNull($content);
        $I->dontSeeInMemcached('test-output');
        $I->clearMemcache();
    }