Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- interface StrategyInterface {
- public function getClassName();
- }
- abstract class StrategyClass implements StrategyInterface {
- public function getClassName() {
- return get_class($this);
- }
- }
- abstract class StrategyDecorator implements StrategyInterface {
- private $decorated;
- public function __construct(StrategyClass $decorated) {
- $this->decorated = $decorated;
- }
- public function getClassName() {
- return $this->decorated->getClassName();
- }
- }
- /**
- * @dataProvider providerForTestGetStrategy
- * @param array $arguments
- * @param string $expected
- */
- public function testGetStrategy($arguments, $expected) {
- $this->assertEquals(
- __NAMESPACE__.'\'.$expected,
- $this->object->getStrategy($arguments)->getClassName()
- )
- }
- //below there's another test to check if proper decorator is being used
- class ProdObj
- {
- ...
- protected:
- virtual bool checkCertainState();
- };
- class TestHelperProdObj : public ProdObj
- {
- ...
- public:
- virtual bool checkCertainState() { return ProdObj::checkCertainState(); }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement