Hoa central
Text.php
Go to the documentation of this file.
1 <?php
2 
38 
40 use Hoa\Test;
41 
50 class Text extends Test\Unit\Suite
51 {
52  public function case_basic()
53  {
54  $this
55  ->given(
56  $text = 'foobar',
57  $content = new SUT($text)
58  )
59  ->when($result = $content->getFormattedContent())
60  ->then
61  ->string($result)
62  ->isEqualTo(
63  'content-transfer-encoding: quoted-printable' . CRLF .
64  'content-disposition: inline' . CRLF .
65  'content-type: text/plain; charset=utf-8' . CRLF .
66  CRLF .
67  'foobar'
68  );
69  }
70 
71  public function case_content_type()
72  {
73  $this
74  ->given($content = new SUT())
75  ->when($result = $content->getHeaders())
76  ->then
77  ->array($result)
78  ->hasKey('content-type')
79  ->string($result['content-type'])
80  ->isEqualTo('text/plain; charset=utf-8');
81  }
82 
83  public function case_no_content_by_default()
84  {
85  $this
86  ->given($content = new SUT())
87  ->when($result = $content->get())
88  ->then
89  ->string($result)
90  ->isEmpty();
91  }
92 
93  public function case_initial_content()
94  {
95  $this
96  ->given(
97  $text = 'foobar',
98  $content = new SUT($text)
99  )
100  ->when($result = $content->get())
101  ->then
102  ->string($result)
103  ->isEqualTo($text);
104  }
105 
106  public function case_append_content()
107  {
108  $this
109  ->given(
110  $te = 'foo',
111  $xt = 'bar',
112  $text = $te . $xt,
113  $content = new SUT()
114  )
115  ->when($result = $content->append($te)->get())
116  ->then
117  ->string($result)
118  ->isEqualTo($te)
119 
120  ->when($result = $content->append($xt)->get())
121  ->then
122  ->string($result)
123  ->isEqualTo($text);
124  }
125 
126  public function case_prepend_content()
127  {
128  $this
129  ->given(
130  $te = 'foo',
131  $xt = 'bar',
132  $text = $te . $xt,
133  $content = new SUT()
134  )
135  ->when($result = $content->append($xt)->get())
136  ->then
137  ->string($result)
138  ->isEqualTo($xt)
139 
140  ->when($result = $content->prepend($te)->get())
141  ->then
142  ->string($result)
143  ->isEqualTo($text);
144  }
145 
146  public function case_get_content()
147  {
148  $this
149  ->given(
150  $text = 'foobar',
151  $content = new SUT($text)
152  )
153  ->when($result = $content->getFormattedContent(false))
154  ->then
155  ->string($result)
156  ->isEqualTo('foobar')
157 
158  ->given(
159  $text = 'fôòbār',
160  $content = new SUT($text)
161  )
162  ->when($result = $content->getFormattedContent(false))
163  ->then
164  ->string($result)
165  ->isEqualTo('f=C3=B4=C3=B2b=C4=81r');
166  }
167 }
$content
Definition: Hoa.php:119