lithium\tests\cases\storage\CacheTest::testKeyWithLambda PHP Method

testKeyWithLambda() public method

public testKeyWithLambda ( )
    public function testKeyWithLambda()
    {
        $key = function () {
            return 'lambda_key';
        };
        $result = Cache::key($key);
        $expected = 'lambda_key';
        $this->assertIdentical($expected, $result);
        $key = function () {
            return 'lambda key';
        };
        $result = Cache::key($key);
        $expected = 'lambda key';
        $this->assertIdentical($expected, $result);
        $key = function ($data = array()) {
            $defaults = array('foo' => 'foo', 'bar' => 'bar');
            $data += $defaults;
            return 'composed_key_with_' . $data['foo'] . '_' . $data['bar'];
        };
        $result = Cache::key($key, array('foo' => 'boo', 'bar' => 'far'));
        $expected = 'composed_key_with_boo_far';
        $this->assertIdentical($expected, $result);
    }