toArray() public method

Convert this attachment to its array representation.
public toArray ( ) : array
return array
Beispiel #1
0
 public function testAttachmentToArray()
 {
     $now = new DateTime();
     $in = ['fallback' => 'Fallback', 'text' => 'Text', 'pretext' => 'Pretext', 'color' => 'bad', 'footer' => 'Footer', 'footer_icon' => 'https://platform.slack-edge.com/img/default_application_icon.png', 'timestamp' => $now, 'mrkdwn_in' => ['pretext', 'text'], 'image_url' => 'http://fake.host/image.png', 'thumb_url' => 'http://fake.host/image.png', 'title' => 'A title', 'title_link' => 'http://fake.host/', 'author_name' => 'Joe Bloggs', 'author_link' => 'http://fake.host/', 'author_icon' => 'http://fake.host/image.png', 'fields' => [['title' => 'Title 1', 'value' => 'Value 1', 'short' => false], ['title' => 'Title 2', 'value' => 'Value 1', 'short' => false]], 'actions' => [['name' => 'Name 1', 'text' => 'Text 1', 'style' => 'default', 'type' => 'button', 'value' => 'Value 1', 'confirm' => ['title' => 'Title 1', 'text' => 'Text 1', 'ok_text' => 'OK Text 1', 'dismiss_text' => 'Dismiss Text 1']], ['name' => 'Name 2', 'text' => 'Text 2', 'style' => 'default', 'type' => 'button', 'value' => 'Value 2', 'confirm' => ['title' => 'Title 2', 'text' => 'Text 2', 'ok_text' => 'OK Text 2', 'dismiss_text' => 'Dismiss Text 2']]]];
     // Sublte difference with timestamp
     $out = ['fallback' => 'Fallback', 'text' => 'Text', 'pretext' => 'Pretext', 'color' => 'bad', 'footer' => 'Footer', 'footer_icon' => 'https://platform.slack-edge.com/img/default_application_icon.png', 'ts' => $now->getTimestamp(), 'mrkdwn_in' => ['pretext', 'text'], 'image_url' => 'http://fake.host/image.png', 'thumb_url' => 'http://fake.host/image.png', 'title' => 'A title', 'title_link' => 'http://fake.host/', 'author_name' => 'Joe Bloggs', 'author_link' => 'http://fake.host/', 'author_icon' => 'http://fake.host/image.png', 'fields' => [['title' => 'Title 1', 'value' => 'Value 1', 'short' => false], ['title' => 'Title 2', 'value' => 'Value 1', 'short' => false]], 'actions' => [['name' => 'Name 1', 'text' => 'Text 1', 'style' => 'default', 'type' => 'button', 'value' => 'Value 1', 'confirm' => ['title' => 'Title 1', 'text' => 'Text 1', 'ok_text' => 'OK Text 1', 'dismiss_text' => 'Dismiss Text 1']], ['name' => 'Name 2', 'text' => 'Text 2', 'style' => 'default', 'type' => 'button', 'value' => 'Value 2', 'confirm' => ['title' => 'Title 2', 'text' => 'Text 2', 'ok_text' => 'OK Text 2', 'dismiss_text' => 'Dismiss Text 2']]]];
     $a = new Attachment($in);
     $this->assertSame($out, $a->toArray());
 }
 public function testAttachmentToArray()
 {
     $array = ['fallback' => 'Fallback', 'text' => 'Text', 'pretext' => 'Pretext', 'color' => 'bad', 'mrkdwn_in' => ['pretext', 'text'], 'image_url' => 'http://fake.host/image.png', 'fields' => [['title' => 'Title 1', 'value' => 'Value 1', 'short' => false], ['title' => 'Title 2', 'value' => 'Value 1', 'short' => false]]];
     $a = new Attachment($array);
     $this->assertSame($array, $a->toArray());
 }