Slack\Test\NotifierTest::testNotify PHP Method

testNotify() public method

public testNotify ( )
    public function testNotify()
    {
        $client = $this->getMockBuilder('\\Slack\\Client')->disableOriginalConstructor()->getMock(array('post'));
        $request = $this->getMockBuilder('\\Guzzle\\Http\\Message\\Request')->disableOriginalConstructor()->getMock(array('send'));
        $message = new Message('Hello world');
        $message->setChannel('#test')->setIconEmoji(':ghost:')->setUsername('slack-php');
        $attachment = new \Slack\Message\MessageAttachment();
        $field = new \Slack\Message\MessageField();
        $field->setTitle('foo')->setValue('bar')->setShort(false);
        $attachment->addField($field);
        $message->addAttachment($attachment);
        $expectedDatas = json_encode(array('text' => $message->getText(), 'channel' => $message->getChannel(), 'username' => 'slack-php', 'icon_emoji' => ':ghost:', 'attachments' => array(array('fields' => array(array('title' => 'foo', 'value' => 'bar', 'short' => false))))));
        $client->expects($this->once())->method('post')->with($this->equalTo('/services/hooks/incoming-webhook'), $this->anything(), $this->equalTo($expectedDatas), $this->anything())->will($this->returnValue($request));
        $notifier = new Notifier($client);
        $notifier->notify($message);
    }