5
5
class CakeRequestTestCase extends CakeTestCase {
6
6
7
7
8
+ /**
9
+ * Tests the request object constructor
10
+ *
11
+ */
8
12
public function testConstruct () {
9
13
$ response = new CakeResponse ();
10
14
$ this ->assertNull ($ response ->body ());
@@ -24,4 +28,60 @@ public function testConstruct() {
24
28
$ this ->assertEquals ($ response ->type (), 'audio/mpeg ' );
25
29
$ this ->assertEquals ($ response ->statusCode (), 203 );
26
30
}
31
+
32
+ /**
33
+ * Tests the body method
34
+ *
35
+ */
36
+ public function testBody () {
37
+ $ response = new CakeResponse ();
38
+ $ this ->assertNull ($ response ->body ());
39
+ $ response ->body ('Response body ' );
40
+ $ this ->assertEquals ($ response ->body (), 'Response body ' );
41
+ $ this ->assertEquals ($ response ->body ('Changed Body ' ), 'Changed Body ' );
42
+ }
43
+
44
+ /**
45
+ * Tests the encoding method
46
+ *
47
+ */
48
+ public function testEncoding () {
49
+ $ response = new CakeResponse ();
50
+ $ this ->assertEquals ($ response ->encoding (), 'UTF-8 ' );
51
+ $ response ->encoding ('iso-8859-1 ' );
52
+ $ this ->assertEquals ($ response ->encoding (), 'iso-8859-1 ' );
53
+ $ this ->assertEquals ($ response ->encoding ('UTF-16 ' ), 'UTF-16 ' );
54
+ }
55
+
56
+ /**
57
+ * Tests the statusCode method
58
+ *
59
+ * @expectedException OutOfRangeException
60
+ */
61
+ public function testStatusCode () {
62
+ $ response = new CakeResponse ();
63
+ $ this ->assertEquals ($ response ->statusCode (), 200 );
64
+ $ response ->statusCode (404 );
65
+ $ this ->assertEquals ($ response ->statusCode (), 404 );
66
+ $ this ->assertEquals ($ response ->statusCode (500 ), 500 );
67
+
68
+ //Throws exception
69
+ $ response ->statusCode (1001 );
70
+ }
71
+
72
+ /**
73
+ * Tests the type method
74
+ *
75
+ */
76
+ public function testType () {
77
+ $ response = new CakeResponse ();
78
+ $ this ->assertEquals ($ response ->type (), 'text/html ' );
79
+ $ response ->type ('pdf ' );
80
+ $ this ->assertEquals ($ response ->type (), 'application/pdf ' );
81
+ $ this ->assertEquals ($ response ->type ('application/crazy-mime ' ), 'application/crazy-mime ' );
82
+ $ this ->assertEquals ($ response ->type ('json ' ), 'application/json ' );
83
+ $ this ->assertEquals ($ response ->type ('wap ' ), 'text/vnd.wap.wml ' );
84
+ $ this ->assertEquals ($ response ->type ('xhtml-mobile ' ), 'application/vnd.wap.xhtml+xml ' );
85
+ $ this ->assertEquals ($ response ->type ('csv ' ), 'text/csv ' );
86
+ }
27
87
}
0 commit comments