Advertisement
Guest User

Untitled

a guest
Nov 27th, 2014
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. interface StrategyInterface {
  2. public function getClassName();
  3. }
  4.  
  5. abstract class StrategyClass implements StrategyInterface {
  6. public function getClassName() {
  7. return get_class($this);
  8. }
  9. }
  10.  
  11. abstract class StrategyDecorator implements StrategyInterface {
  12.  
  13. private $decorated;
  14.  
  15. public function __construct(StrategyClass $decorated) {
  16. $this->decorated = $decorated;
  17. }
  18.  
  19. public function getClassName() {
  20. return $this->decorated->getClassName();
  21. }
  22.  
  23. }
  24.  
  25. /**
  26. * @dataProvider providerForTestGetStrategy
  27. * @param array $arguments
  28. * @param string $expected
  29. */
  30. public function testGetStrategy($arguments, $expected) {
  31.  
  32. $this->assertEquals(
  33. __NAMESPACE__.'\'.$expected,
  34. $this->object->getStrategy($arguments)->getClassName()
  35. )
  36. }
  37.  
  38. //below there's another test to check if proper decorator is being used
  39.  
  40. class ProdObj
  41. {
  42. ...
  43. protected:
  44. virtual bool checkCertainState();
  45. };
  46.  
  47. class TestHelperProdObj : public ProdObj
  48. {
  49. ...
  50. public:
  51. virtual bool checkCertainState() { return ProdObj::checkCertainState(); }
  52. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement