public function testGetMentions() { $fooBarUsernames = ['foo', 'bar']; $fooBarDto = [m::mock(ConfirmedMentionDto::class), m::mock(ConfirmedMentionDto::class)]; $fooBarEntities = [m::mock(Mention::class), m::mock(Mention::class)]; $this->mentionsParser->shouldReceive('findMentions')->with('Hello @foo and @bar')->once()->andReturn($fooBarUsernames); $this->mentionsFetcher->shouldReceive('fetchMentions')->with($fooBarUsernames)->once()->andReturn($fooBarDto); $this->mentionsMapper->shouldReceive('map')->with($fooBarDto)->once()->andReturn($fooBarEntities); $entities = $this->mentionsResolver->getMentions('Hello @foo and @bar'); $this->assertEquals($fooBarEntities, $entities); }
/** * @param string $text * * @return Mention[] */ public function getMentions(string $text) : array { $usernames = $this->mentionsParser->findMentions($text); $confirmedMentions = $this->mentionsFetcher->fetchMentions($usernames); return $this->mentionsMapper->map($confirmedMentions); }