File tree Expand file tree Collapse file tree 2 files changed +51
-0
lines changed Expand file tree Collapse file tree 2 files changed +51
-0
lines changed Original file line number Diff line number Diff line change @@ -199,6 +199,30 @@ public function __construct() {
199
199
}
200
200
}
201
201
202
+ /**
203
+ * Set From
204
+ *
205
+ * @param string $email
206
+ * @param string $name
207
+ * @return void
208
+ */
209
+ public function setFrom ($ email , $ name = null ) {
210
+ if ($ name !== null ) {
211
+ $ this ->_from = array ($ email => $ name );
212
+ } else {
213
+ $ this ->_from = array ($ email => $ email );
214
+ }
215
+ }
216
+
217
+ /**
218
+ * Get the From information
219
+ *
220
+ * @return array Key is email, Value is name. If Key is equal of Value, the name is not specified
221
+ */
222
+ public function getFrom () {
223
+ return $ this ->_from ;
224
+ }
225
+
202
226
/**
203
227
* Sets headers for the message
204
228
*
Original file line number Diff line number Diff line change 25
25
*/
26
26
class CakeEmailTest extends CakeTestCase {
27
27
28
+ /**
29
+ * setUp
30
+ *
31
+ * @return void
32
+ */
33
+ public function setUp () {
34
+ parent ::setUp ();
35
+ $ this ->CakeEmail = new CakeEmail ();
36
+ }
37
+
38
+ /**
39
+ * testFrom method
40
+ *
41
+ * @return void
42
+ */
43
+ public function testFrom () {
44
+ $ this ->assertIdentical ($ this ->CakeEmail ->getFrom (), array ());
45
+
46
+ $ this ->CakeEmail ->setFrom ('cake@cakephp.org ' );
47
+ $ expected = array ('cake@cakephp.org ' => 'cake@cakephp.org ' );
48
+ $ this ->assertIdentical ($ this ->CakeEmail ->getFrom (), $ expected );
49
+
50
+ $ this ->CakeEmail ->setFrom ('cake@cakephp.org ' , 'CakePHP ' );
51
+ $ expected = array ('cake@cakephp.org ' => 'CakePHP ' );
52
+ $ this ->assertIdentical ($ this ->CakeEmail ->getFrom (), $ expected );
53
+ }
54
+
28
55
/**
29
56
* testHeaders method
30
57
*
You can’t perform that action at this time.
0 commit comments