Hoa central
Alternative.php
Go to the documentation of this file.
1 <?php
2 
38 
42 use Hoa\Test;
43 
53 {
54  public function case_content_type()
55  {
56  $this
57  ->when($result = new SUT())
58  ->then
59  ->string($result['content-type'])
60  ->isEqualTo('multipart/alternative');
61  }
62 
64  {
65  $this
66  ->given(
67  $content1 = new Text('foo'),
68  $content2 = new Text('bar'),
69  $alternative = new SUT([$content1, $content2])
70  )
71  ->when($result = count($alternative->getContent()))
72  ->then
73  ->integer($result)
74  ->isEqualTo(2);
75  }
76 
77  public function case_basic()
78  {
79  $this
80  ->given(
81  $this->function->microtime = function () use (&$microtime) {
82  return $microtime = 42;
83  },
84  $content1 = new Text('foo'),
85  $content2 = new Html('<strong>foo</strong>'),
86  $alternative = new SUT([$content1, $content2])
87  )
88  ->when($result = $alternative->getFormattedContent())
89  ->then
90  ->string($result)
91  ->isEqualTo(
92  'content-type: multipart/alternative; boundary="__bndry-3d469222fa3ab341c0d491b98a8aa315"' . CRLF .
93  CRLF .
94 
95  // Content 1.
96  '--__bndry-3d469222fa3ab341c0d491b98a8aa315' . CRLF .
97  $content1->getFormattedContent() . CRLF .
98 
99  // Content 2.
100  '--__bndry-3d469222fa3ab341c0d491b98a8aa315' . CRLF .
101  $content2->getFormattedContent() . CRLF .
102 
103  '--__bndry-3d469222fa3ab341c0d491b98a8aa315' .
104  '--' . CRLF
105  );
106  }
107 }