File tree 3 files changed +36
-1
lines changed
3 files changed +36
-1
lines changed Original file line number Diff line number Diff line change @@ -134,4 +134,16 @@ public function getContent()
134
134
{
135
135
return false ;
136
136
}
137
+
138
+ /**
139
+ * {@inheritdoc}
140
+ *
141
+ * @return $this
142
+ */
143
+ public function setNotModified ()
144
+ {
145
+ $ this ->setCallback (function () {});
146
+
147
+ return parent ::setNotModified ();
148
+ }
137
149
}
Original file line number Diff line number Diff line change @@ -126,7 +126,7 @@ public function testMustRevalidateWithProxyRevalidateCacheControlHeader()
126
126
127
127
public function testSetNotModified ()
128
128
{
129
- $ response = new Response ();
129
+ $ response = new Response (' foo ' );
130
130
$ modified = $ response ->setNotModified ();
131
131
$ this ->assertObjectHasAttribute ('headers ' , $ modified );
132
132
$ this ->assertObjectHasAttribute ('content ' , $ modified );
@@ -135,6 +135,11 @@ public function testSetNotModified()
135
135
$ this ->assertObjectHasAttribute ('statusText ' , $ modified );
136
136
$ this ->assertObjectHasAttribute ('charset ' , $ modified );
137
137
$ this ->assertEquals (304 , $ modified ->getStatusCode ());
138
+
139
+ ob_start ();
140
+ $ modified ->sendContent ();
141
+ $ string = ob_get_clean ();
142
+ $ this ->assertEmpty ($ string );
138
143
}
139
144
140
145
public function testIsSuccessful ()
Original file line number Diff line number Diff line change @@ -132,4 +132,22 @@ public function testReturnThis()
132
132
$ this ->assertInstanceOf ('Symfony\Component\HttpFoundation\StreamedResponse ' , $ response ->sendHeaders ());
133
133
$ this ->assertInstanceOf ('Symfony\Component\HttpFoundation\StreamedResponse ' , $ response ->sendHeaders ());
134
134
}
135
+
136
+ public function testSetNotModified ()
137
+ {
138
+ $ response = new StreamedResponse (function () { echo 'foo ' ; });
139
+ $ modified = $ response ->setNotModified ();
140
+ $ this ->assertObjectHasAttribute ('headers ' , $ modified );
141
+ $ this ->assertObjectHasAttribute ('content ' , $ modified );
142
+ $ this ->assertObjectHasAttribute ('version ' , $ modified );
143
+ $ this ->assertObjectHasAttribute ('statusCode ' , $ modified );
144
+ $ this ->assertObjectHasAttribute ('statusText ' , $ modified );
145
+ $ this ->assertObjectHasAttribute ('charset ' , $ modified );
146
+ $ this ->assertEquals (304 , $ modified ->getStatusCode ());
147
+
148
+ ob_start ();
149
+ $ modified ->sendContent ();
150
+ $ string = ob_get_clean ();
151
+ $ this ->assertEmpty ($ string );
152
+ }
135
153
}
You can’t perform that action at this time.
0 commit comments