예제 #1
0
 /**
  * Remove a comment
  *
  * @param CommentInterface $comment Comment
  *
  * @return $this Self object
  */
 public function removeComment(CommentInterface $comment)
 {
     $this->commentEventDispatcher->dispatchCommentPreRemoveEvent($comment);
     $this->commentDirector->save($comment);
     $this->commentEventDispatcher->dispatchCommentOnRemoveEvent($comment);
     return $this;
 }
예제 #2
0
 /**
  * Get comment votes
  *
  * @param CommentInterface $comment Comment
  *
  * @return VotePackage Vote package
  */
 public function getCommentVotes(CommentInterface $comment)
 {
     /**
      * @var VoteInterface[] $votes
      */
     $votes = $this->commentVoteObjectDirector->findBy(['comment' => $comment]);
     return VotePackage::create($votes);
 }
 /**
  * Test that modifying a new root category the parent category should be
  * null.
  */
 public function testEditRootCategoryIsSavedWithoutParent()
 {
     /**
      * @var $rootCategory CategoryInterface
      */
     $rootCategory = $this->categoryDirector->findOneBy(['slug' => 'root-category']);
     /**
      * @var $anotherCategory CategoryInterface
      */
     $anotherCategory = $this->categoryDirector->findOneBy(['slug' => 'category']);
     $rootCategory->setParent($anotherCategory);
     $this->categoryDirector->save($rootCategory);
     /**
      * @var $category CategoryInterface
      */
     $category = $this->categoryDirector->findOneBy(['slug' => 'root-category']);
     $this->assertNull($category->getParent(), 'The parent for a root category should always be null');
 }
예제 #4
0
 /**
  * Drops the country and its relations.
  *
  * @param LocationInterface $location The location to remove
  * @param OutputInterface   $output   A console output
  *
  * @return $this Self object
  */
 private function dropCountry(LocationInterface $location, OutputInterface $output)
 {
     $countryCode = $location->getCode();
     $this->startStopWatch('drop_location');
     $this->locationDirector->remove($location);
     $stopWatchEvent = $this->stopStopWatch('drop_location');
     $this->printMessage($output, 'Geo', 'Country ' . $countryCode . ' dropped in ' . $stopWatchEvent->getDuration() . ' milliseconds');
     return $this;
 }
예제 #5
0
 /**
  * Create a new user from a response
  *
  * @param UserResponseInterface $response
  *
  * @return UserInterface
  */
 protected function createUser(UserResponseInterface $response)
 {
     /**
      * @var CustomerInterface $customer
      */
     $customer = $this->customerDirector->create();
     $customer->setEmail($response->getEmail())->setFirstname($response->getRealName());
     $this->customerDirector->save($customer);
     $this->userEventDispatcher->dispatchOnCustomerRegisteredEvent($customer);
     return $customer;
 }
 /**
  * Populates the exchange rates.
  *
  * @return $this Self object
  */
 public function populate()
 {
     $currenciesCodes = [];
     $currencies = $this->currencyRepository->findAll();
     /**
      * Create an array of all active currency codes.
      *
      * @var CurrencyInterface $currency
      */
     foreach ($currencies as $currency) {
         if ($currency->getIso() != $this->defaultCurrency) {
             $currenciesCodes[] = $currency->getIso();
         }
     }
     /**
      * Get rates for all of the enabled and active currencies.
      */
     $rates = $this->currencyExchangeRatesAdapter->getExchangeRates($this->defaultCurrency, $currenciesCodes);
     /**
      * @var CurrencyInterface $sourceCurrency
      */
     $sourceCurrency = $this->currencyRepository->findOneBy(['iso' => $this->defaultCurrency]);
     /**
      * [
      *      "EUR" => "1,378278",
      *      "YEN" => "0,784937",
      * ].
      */
     foreach ($rates as $code => $rate) {
         /**
          * @var CurrencyInterface $targetCurrency
          */
         $targetCurrency = $this->currencyRepository->findOneBy(['iso' => $code]);
         if (!$targetCurrency instanceof CurrencyInterface) {
             continue;
         }
         /**
          * check if this is a new exchange rate, or if we have to
          * create a new one.
          */
         $exchangeRate = $this->currencyExchangeRateObjectDirector->findOneBy(['sourceCurrency' => $sourceCurrency, 'targetCurrency' => $targetCurrency]);
         if (!$exchangeRate instanceof CurrencyExchangeRateInterface) {
             $exchangeRate = $this->currencyExchangeRateObjectDirector->create();
         }
         $exchangeRate->setExchangeRate($rate)->setSourceCurrency($sourceCurrency)->setTargetCurrency($targetCurrency);
         $this->currencyExchangeRateObjectDirector->save($exchangeRate);
     }
     return $this;
 }
 /**
  * Gets a new product entity.
  *
  * @return ProductInterface
  */
 public function getNewProduct()
 {
     return $this->productDirector->create();
 }
예제 #8
0
 /**
  * Setup
  */
 public function setUp()
 {
     $this->commentObjectDirector = $this->getMock('Elcodi\\Component\\Core\\Services\\ObjectDirector', [], [], '', false);
     $this->commentObjectDirector->expects($this->any())->method('create')->will($this->returnValue(new Comment()));
     $this->commentManager = new CommentManager($this->getMock('Elcodi\\Component\\Comment\\EventDispatcher\\CommentEventDispatcher', [], [], '', false), $this->commentObjectDirector);
 }
예제 #9
0
 /**
  * Create new CartCouponManager instance
  *
  * @return CartCouponManager
  */
 private function createCartCouponManagerInstance()
 {
     return new CartCouponManager($this->cartCouponEventDispatcher->reveal(), $this->couponRepository->reveal(), $this->cartCouponDirector->reveal(), $this->cartCouponRepository->reveal());
 }
예제 #10
0
 /**
  * Removed a CartCoupon.
  *
  * @param CartCouponInterface $cartCoupon Cart coupon
  */
 public function removeCartCoupon(CartCouponInterface $cartCoupon)
 {
     $this->cartCouponDirector->remove($cartCoupon);
 }
예제 #11
0
 /**
  * Test remove vote when no exists.
  */
 public function testRemoveNonExistingVote()
 {
     $this->voteDirector->expects($this->any())->method('findOneBy')->will($this->returnValue(null));
     $this->voteDirector->expects($this->never())->method('remove');
     $this->voteManager->removeVote($this->comment, $this->authorToken, Vote::DOWN);
 }