PayPal\Test\Functional\Api\BillingPlansFunctionalTest::getPlan PHP Method

getPlan() public static method

Helper function to get a Plan object in Active State
public static getPlan ( ) : PayPal\Api\Plan
return PayPal\Api\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;
    }

Usage Example

 /**
  * @return Agreement
  */
 public function testCreateCCAgreement()
 {
     $plan = BillingPlansFunctionalTest::getPlan();
     $request = $this->operation['request']['body'];
     $agreement = new Agreement($request);
     // Update the Schema to use a working Plan
     $agreement->getPlan()->setId($plan->getId());
     $result = $agreement->create($this->apiContext, $this->mockPayPalRestCall);
     $this->assertNotNull($result);
     return $result;
 }