public function testSend() { $user = $this->getMockForAbstractClass('Symfony\\Component\\Security\\Core\\User\\UserInterface'); $user->expects($this->any())->method('getUserName')->will($this->returnValue(self::TEST_USERNAME)); $token = $this->getMock('Symfony\\Component\\Security\\Core\\Authentication\\Token\\TokenInterface'); $token->expects($this->any())->method('getUser')->will($this->returnValue($user)); $this->securityContext->expects($this->any())->method('getToken')->will($this->returnValue($token)); $that = $this; $this->publisher->expects($this->once())->method('send')->will($this->returnCallback(function ($topic, $payload) use($that) { $that->assertSame('oro/data/update', $topic, 'Should be the same as frontend code expects'); $tags = json_decode($payload, true); $that->assertCount(2, $tags); foreach ($tags as $tag) { $that->assertArrayHasKey('username', $tag); $that->assertArrayHasKey('tagname', $tag); $that->assertSame(self::TEST_USERNAME, $tag['username']); } })); $tags = [self::TEST_TAG1, self::TEST_TAG2]; $this->sender->send($tags); }
/** * Send collected tags to publisher */ public function postFlush(PostFlushEventArgs $event) { $this->sender->send($this->collectedTags); $this->collectedTags = []; }