/** * @return bool */ private function expired() { if (null !== ($subscription = $this->subscriptionProvider->getSubscription())) { if ($subscription->expired()) { return true; } } return false; }
/** * @param SubscriptionCancelCommand $message * * @throws \Baboon\SubscriptionBundle\Exception\PackageNotFoundException * @throws \Baboon\SubscriptionBundle\Exception\SubscriptionManageException */ public function cancelSubscription(SubscriptionCancelCommand $message) { if (null === ($package = $this->packageManager->findInitial())) { throw new PackageNotFoundException('Initial package'); } $currentPackage = $this->subscriptionProvider->getPackage(); if (null !== $currentPackage && $currentPackage->isInitial()) { throw new SubscriptionManageException(sprintf('Current package "%s" not cancelable', $currentPackage)); } if (null !== ($subscription = $this->subscriptionProvider->getSubscription())) { $subscription->select($package); $this->subscriptionManager->updateSubscription($subscription); $this->eventRecorder->record(new SubscriptionCanceledEvent($subscription)); } }
/** * @return PackageInterface|null */ public function getCurrentPackage() { return $this->subscriptionProvider->getPackage(); }
public function testGetCurrentPackage() { $this->subscriptionProvider->expects($this->once())->method('getPackage')->will($this->returnValue($this->currentPackage)); $this->assertEquals($this->currentPackage, $this->extension->getCurrentPackage()); }