Phalcon\Test\Unit\Cache\Backend\MemoryCest::get PHP Method

get() public method

public get ( UnitTester $I )
$I UnitTester
    public function get(UnitTester $I)
    {
        $I->wantTo('Get cached by using Memory as cache backend');
        $key = 'data-get';
        $data = [uniqid(), gethostname(), microtime(), get_include_path(), time()];
        $cache = new Memory(new Data(['lifetime' => 20]));
        $I->setProtectedProperty($cache, '_data', [$key => serialize($data)]);
        $I->assertEquals($data, $cache->get($key));
        $I->assertNull($cache->get('non-existent-key'));
        $I->assertEquals([$key => serialize($data)], $I->getProtectedProperty($cache, '_data'));
        $I->setProtectedProperty($cache, '_data', [$key => 100]);
        $I->assertEquals(100, $cache->get($key));
        $I->assertEquals([$key => 100], $I->getProtectedProperty($cache, '_data'));
    }