Programming Language PHP

Namespace Oro\Bundle\SalesBundle\Entity

Class Opportunity

Method/Function setCloseRevenue

Total Examples 1

1 code examples of PHP Oro\Bundle\SalesBundle\Entity\Opportunity::setCloseRevenue extracted from open source projects

Was this example useful?
0
                                                    /**
     * @depends testCreateAffectsLifetimeIfValuable
     */
    public function testChangeStatusAffectsLifetime(Opportunity $opportunity): Opportunity
    {
        $em = $this->getEntityManager();
        $b2bCustomer = $opportunity->getCustomerAssociation()->getTarget();
        $enumClass = ExtendHelper::buildEnumValueClassName(Opportunity::INTERNAL_STATUS_CODE);
        $opportunity->setStatus($em->getReference($enumClass, 'lost'));

        $em->persist($opportunity);
        $em->flush();
        $em->refresh($b2bCustomer);

        $this->assertEquals(0, $b2bCustomer->getLifetime());

        $opportunity->setStatus($em->getReference($enumClass, 'won'));
        $closeRevenue = MultiCurrency::create(100, 'USD');
        $opportunity->setCloseRevenue($closeRevenue);

        $em->persist($opportunity);
        $em->flush();
        $em->refresh($b2bCustomer);

        $this->assertEquals(100, $b2bCustomer->getLifetime());

        return $opportunity;
    }