6
6
7
7
use Debril \RssAtomBundle \Request \ModifiedSince ;
8
8
use PHPUnit \Framework \TestCase ;
9
+ use Psr \Log \NullLogger ;
9
10
use Symfony \Component \HttpFoundation \Request ;
10
11
use Symfony \Component \HttpFoundation \RequestStack ;
11
12
@@ -20,7 +21,42 @@ public function testGetValue()
20
21
$ request ->headers ->set ('If-Modified-Since ' , $ date ->format (\DATE_RSS ));
21
22
$ stack ->push ($ request );
22
23
23
- $ modifiedSince = new ModifiedSince ($ stack );
24
+ $ modifiedSince = new ModifiedSince ($ stack , new NullLogger ());
25
+ $ this ->assertEquals ($ date , $ modifiedSince ->getValue ());
26
+ }
27
+
28
+ public function testGetBadValue ()
29
+ {
30
+ $ stack = new RequestStack ();
31
+ $ request = new Request ();
32
+ $ request ->headers ->set ('If-Modified-Since ' , 'something that is not a date ' );
33
+ $ stack ->push ($ request );
34
+
35
+ $ modifiedSince = new ModifiedSince ($ stack , new NullLogger ());
36
+ $ this ->assertInstanceOf ('\DateTime ' , $ modifiedSince ->getValue ());
37
+ }
38
+
39
+ public function testGetEmptyArrayValue ()
40
+ {
41
+ $ stack = new RequestStack ();
42
+ $ request = new Request ();
43
+ $ request ->headers ->set ('If-Modified-Since ' , array ());
44
+ $ stack ->push ($ request );
45
+
46
+ $ modifiedSince = new ModifiedSince ($ stack , new NullLogger ());
47
+ $ this ->assertInstanceOf ('\DateTime ' , $ modifiedSince ->getValue ());
48
+ }
49
+
50
+
51
+ public function testGetValueInArray ()
52
+ {
53
+ $ stack = new RequestStack ();
54
+ $ request = new Request ();
55
+ $ date = new \DateTime ('2018-06-01 ' );
56
+ $ request ->headers ->set ('If-Modified-Since ' , [$ date ->format (\DATE_RSS )]);
57
+ $ stack ->push ($ request );
58
+
59
+ $ modifiedSince = new ModifiedSince ($ stack , new NullLogger ());
24
60
$ this ->assertEquals ($ date , $ modifiedSince ->getValue ());
25
61
}
26
62
0 commit comments