Advertisement
Guest User

Untitled

a guest
Jul 8th, 2014
827
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. private $collection;
  4. const ONE = 1;
  5. const KLASS = 'Collection';
  6. const ELEMENT = 'any element';
  7. const PROPERTY = 'collection';
  8.  
  9. public function testSizeOfTheCollectionReflectsNewElements()
  10. {
  11.     $this->startWithAnEmptyCollection();
  12.  
  13.     $this->addAnyElementToTheCollection();
  14.  
  15.     $this->theSizeOfTheCollectionIsOne();
  16. }
  17.  
  18. private function theSizeOfTheCollectionIsOne()
  19. {
  20.     $this->theSizeOfTheCollectionIs($this->one());
  21. }
  22.  
  23. private function one()
  24. {
  25.     return self::ONE;
  26. }
  27.  
  28. private function startWithAnEmptyCollection()
  29. {
  30.     $this->setProperty($this->aProperty(), $this->anEmptyCollection());
  31. }
  32.  
  33. private function aProperty()
  34. {
  35.     return self::PROPERTY;
  36. }
  37.  
  38. private function setProperty($name, $value)
  39. {
  40.     $this->{$name} = $value;
  41. }
  42.  
  43. private function anEmptyCollection()
  44. {
  45.     return new $this->aClass;
  46. }
  47.  
  48. private function aClass()
  49. {
  50.     return self::KLASS;
  51. }
  52.  
  53. private function addAnyElementToTheCollection()
  54. {
  55.     $this->theCollection()->add($this->anyElement());
  56. }
  57.  
  58. private function anyElement()
  59. {
  60.     return self::ELEMENT;
  61. }
  62.  
  63. private function theSizeOfTheCollectionIs($size)
  64. {
  65.     $this->assertSame($size, $this->theSizeOfTheCollection());
  66. }
  67.  
  68. private function theSizeOfTheCollection()
  69. {
  70.     return count($this->theCollection());
  71. }
  72.  
  73. private function theCollection()
  74. {
  75.     return $this->collection;
  76. }
Advertisement
RAW Paste Data Copied
Advertisement