public function testProcessValidData() { /** @var Account $appendedAccount */ $appendedAccount = $this->getEntity('OroB2B\\Bundle\\AccountBundle\\Entity\\Account', 1); /** @var Account $removedAccount */ $removedAccount = $this->getEntity('OroB2B\\Bundle\\AccountBundle\\Entity\\Account', 2); $this->entity->addAccount($removedAccount); /** @var AccountGroup $appendedAccountGroup */ $appendedAccountGroup = $this->getEntity('OroB2B\\Bundle\\AccountBundle\\Entity\\AccountGroup', 1); /** @var AccountGroup $removedAccountGroup */ $removedAccountGroup = $this->getEntity('OroB2B\\Bundle\\AccountBundle\\Entity\\AccountGroup', 2); $this->entity->addAccountGroup($removedAccountGroup); /** @var Website $appendedWebsite */ $appendedWebsite = $this->getEntity('OroB2B\\Bundle\\WebsiteBundle\\Entity\\Website', 1); /** @var Website $removedWebsite */ $removedWebsite = $this->getEntity('OroB2B\\Bundle\\WebsiteBundle\\Entity\\Website', 2); $this->entity->addWebsite($removedWebsite); $this->form->expects($this->atLeastOnce())->method('get')->willReturnMap([['appendAccounts', $this->getFormForEntity($appendedAccount)], ['removeAccounts', $this->getFormForEntity($removedAccount)], ['appendAccountGroups', $this->getFormForEntity($appendedAccountGroup)], ['removeAccountGroups', $this->getFormForEntity($removedAccountGroup)], ['appendWebsites', $this->getFormForEntity($appendedWebsite)], ['removeWebsites', $this->getFormForEntity($removedWebsite)]]); $this->prepareServices(); $this->assertTrue($this->handler->process($this->entity)); $this->assertFalse($this->entity->getAccounts()->contains($removedAccount)); $this->assertFalse($this->entity->getAccountGroups()->contains($removedAccountGroup)); $this->assertFalse($this->entity->getWebsites()->contains($removedWebsite)); $this->assertTrue($this->entity->getAccounts()->contains($appendedAccount)); $this->assertTrue($this->entity->getAccountGroups()->contains($appendedAccountGroup)); $this->assertTrue($this->entity->getWebsites()->contains($appendedWebsite)); }
public function testProcessValidData() { /** @var Customer $appendedCustomer */ $appendedCustomer = $this->getEntity('OroB2B\\Bundle\\CustomerBundle\\Entity\\Customer', 1); /** @var Customer $removedCustomer */ $removedCustomer = $this->getEntity('OroB2B\\Bundle\\CustomerBundle\\Entity\\Customer', 2); $this->entity->addCustomer($removedCustomer); /** @var CustomerGroup $appendedCustomerGroup */ $appendedCustomerGroup = $this->getEntity('OroB2B\\Bundle\\CustomerBundle\\Entity\\CustomerGroup', 1); /** @var CustomerGroup $removedCustomerGroup */ $removedCustomerGroup = $this->getEntity('OroB2B\\Bundle\\CustomerBundle\\Entity\\CustomerGroup', 2); $this->entity->addCustomerGroup($removedCustomerGroup); /** @var Website $appendedWebsite */ $appendedWebsite = $this->getEntity('OroB2B\\Bundle\\WebsiteBundle\\Entity\\Website', 1); /** @var Website $removedWebsite */ $removedWebsite = $this->getEntity('OroB2B\\Bundle\\WebsiteBundle\\Entity\\Website', 2); $this->entity->addWebsite($removedWebsite); $this->form->expects($this->atLeastOnce())->method('get')->willReturnMap([['appendCustomers', $this->getFormForEntity($appendedCustomer)], ['removeCustomers', $this->getFormForEntity($removedCustomer)], ['appendCustomerGroups', $this->getFormForEntity($appendedCustomerGroup)], ['removeCustomerGroups', $this->getFormForEntity($removedCustomerGroup)], ['appendWebsites', $this->getFormForEntity($appendedWebsite)], ['removeWebsites', $this->getFormForEntity($removedWebsite)]]); $this->prepareServices(); $this->assertTrue($this->handler->process($this->entity)); $this->assertFalse($this->entity->getCustomers()->contains($removedCustomer)); $this->assertFalse($this->entity->getCustomerGroups()->contains($removedCustomerGroup)); $this->assertFalse($this->entity->getWebsites()->contains($removedWebsite)); $this->assertTrue($this->entity->getCustomers()->contains($appendedCustomer)); $this->assertTrue($this->entity->getCustomerGroups()->contains($appendedCustomerGroup)); $this->assertTrue($this->entity->getWebsites()->contains($appendedWebsite)); }