コード例 #1
0
 protected function prepareServices()
 {
     $this->form->expects($this->once())->method('setData')->with($this->entity);
     $this->form->expects($this->once())->method('submit')->with($this->request);
     $this->request->setMethod('POST');
     $this->form->expects($this->once())->method('isValid')->willReturn(true);
     $this->manager->expects($this->at(0))->method('persist')->with($this->isType('object'));
     $repository = $this->getMockBuilder('OroB2B\\Bundle\\PricingBundle\\Entity\\Repository\\PriceListRepository')->disableOriginalConstructor()->getMock();
     $repository->expects($this->any())->method('setPriceListToCustomer')->will($this->returnCallback(function (Customer $customer, PriceList $priceList = null) {
         $this->entity->removeCustomer($customer);
         if ($priceList) {
             $this->entity->addCustomer($customer);
         }
     }));
     $repository->expects($this->any())->method('setPriceListToCustomerGroup')->will($this->returnCallback(function (CustomerGroup $customerGroup, PriceList $priceList = null) {
         $this->entity->removeCustomerGroup($customerGroup);
         if ($priceList) {
             $this->entity->addCustomerGroup($customerGroup);
         }
     }));
     $repository->expects($this->any())->method('setPriceListToWebsite')->will($this->returnCallback(function (Website $website, PriceList $priceList = null) {
         $this->entity->removeWebsite($website);
         if ($priceList) {
             $this->entity->addWebsite($website);
         }
     }));
     $this->manager->expects($this->any())->method('getRepository')->with($this->isType('string'))->willReturn($repository);
     $this->manager->expects($this->exactly(2))->method('flush');
 }