CacheTest::testDataMongoCache PHP Method

testDataMongoCache() public method

public testDataMongoCache ( )
    public function testDataMongoCache()
    {
        list($ready, $collection) = $this->_prepareMongo();
        if (!$ready) {
            return false;
        }
        // Travis can be slow, especially when Valgrind is used
        $frontCache = new Phalcon\Cache\Frontend\Data(array('lifetime' => 900));
        $cache = new Phalcon\Cache\Backend\Mongo($frontCache, array('mongo' => $ready, 'db' => 'phalcon_test', 'collection' => 'caches'));
        $data = array(1, 2, 3, 4, 5);
        $cache->save('test-data', $data);
        $cachedContent = $cache->get('test-data');
        $this->assertEquals($cachedContent, $data);
        $cache->save('test-data', "sure, nothing interesting");
        $cachedContent = $cache->get('test-data');
        $this->assertEquals($cachedContent, "sure, nothing interesting");
        //Exists
        $this->assertTrue($cache->exists('test-data'));
        $this->assertTrue($cache->delete('test-data'));
    }