Skip to content

final CacheItem not mockable in tests #23464

@cjost1988

Description

@cjost1988
Q A
Bug report? yes
Feature request? no
BC Break report? no
RFC? no
Symfony version 3.2.11

Good morning,
I am using the tagging of CacheItems in my project and have a small issue with the class definition of the CacheItem.

Since the tag method is not defined in the PSR\CacheItemInterface and the CacheItem is final it's impossible to mock CacheItems in tests in a proper way.
My suggestion would be to add an interface that extends the CacheItemInterface and will be implemented by the CacheItem.

interface TagAwareCacheItemInterface extends CacheItemInterface
{
    // ...
    public function tag(array $tags);
}

class CacheItem extends TagAwareCacheItemInterface
{
}

I think this should not break BC, correct me if I am wrong.

Cheers,
Christian

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions