/**
  * Helper function to get a Plan object in Active State
  *
  * @return Plan
  */
 public static function getPlan()
 {
     if (!self::$obj) {
         $test = new self();
         // Creates a Plan
         $test->setupTest($test->getClassName(), 'testCreate');
         self::$obj = $test->testCreate();
         // Updates the Status to Active
         $test->setupTest($test->getClassName(), 'testUpdateChangingState');
         self::$obj = $test->testUpdateChangingState(self::$obj);
     }
     return self::$obj;
 }
Example #2
0
 public static function mock($className, $custom = null, $constructorArgs = null)
 {
     if (is_array($custom) && !class_exists($className)) {
         $mockery = new self($className);
         $mockery->createStubObject();
     } else {
         if (is_array($custom)) {
             $mockery = new self($className, null);
         } else {
             $mockery = new self($className, $custom);
         }
         $mockery->createMockObject();
     }
     if ($mockery->getMockClassName() === null) {
         $class = $mockery->getClassName();
     } else {
         $class = $mockery->getMockClassName();
     }
     if (is_array($constructorArgs)) {
         $reflectionObject = new ReflectionClass($class);
         $mockObject = $reflectionObject->newInstanceArgs($constructorArgs);
     } else {
         $mockObject = new $class();
     }
     if ($mockObject instanceof Mockery_Stub && is_array($custom)) {
         $mockObject->mockery_set($custom);
     } elseif (is_array($custom)) {
         foreach ($custom as $method => $return) {
             $mockObject->shouldReceive($method)->withAnyArgs()->zeroOrMoreTimes()->andReturn($return);
         }
     }
     if (!$mockObject instanceof Mockery_Stub) {
         self::$_mockedObjects[] = $mockObject;
     }
     return $mockObject;
 }