예제 #1
0
 public function testPostFlush()
 {
     $args = new PostFlushEventArgs($this->em);
     $account = $this->getMock('OroCRM\\Bundle\\AccountBundle\\Entity\\Account');
     $channel = $this->getMock('OroCRM\\Bundle\\ChannelBundle\\Entity\\Channel');
     $channel->expects($this->any())->method('getId')->will($this->returnValue(1));
     $account2 = clone $account;
     $queue = ['OroCRM\\Bundle\\ChannelBundle\\Tests\\Unit\\Stubs\\Entity\\Customer' => [uniqid('accountId__channelId', true) => ['account' => $account, 'channel' => $channel], uniqid('accountId__channelId', true) => ['account' => $account2, 'channel' => $channel]]];
     $this->lifetimeRepo->expects($this->exactly(2))->method('calculateAccountLifetime')->with($this->equalTo('OroCRM\\Bundle\\ChannelBundle\\Tests\\Unit\\Stubs\\Entity\\Customer'), $this->equalTo('lifetime'), $this->isInstanceOf('OroCRM\\Bundle\\AccountBundle\\Entity\\Account'), $this->isInstanceOf('OroCRM\\Bundle\\ChannelBundle\\Entity\\Channel'))->will($this->onConsecutiveCalls(100, 200));
     $this->em->expects($this->exactly(2))->method('persist');
     $this->em->expects($this->once())->method('flush');
     $reflectionProperty = new \ReflectionProperty(get_class($this->channelDoctrineListener), 'queued');
     $reflectionProperty->setAccessible(true);
     $reflectionProperty->setValue($this->channelDoctrineListener, $queue);
     $this->channelDoctrineListener->postFlush($args);
 }