99
1010namespace Webfactory \HttpCacheBundle \Tests \NotModified \Annotation ;
1111
12+ use DateTime ;
13+ use PHPUnit_Framework_MockObject_MockObject ;
14+ use PHPUnit_Framework_TestCase ;
15+ use RuntimeException ;
1216use Symfony \Component \DependencyInjection \ContainerInterface ;
1317use Symfony \Component \HttpFoundation \Request ;
1418use Webfactory \HttpCacheBundle \NotModified \Annotation \ReplaceWithNotModifiedResponse ;
1721/**
1822 * Tests for the ReplaceWithNotModifiedResponse annotation.
1923 */
20- final class ReplaceWithNotModifiedResponseTest extends \ PHPUnit_Framework_TestCase
24+ final class ReplaceWithNotModifiedResponseTest extends PHPUnit_Framework_TestCase
2125{
2226 /**
2327 * @test
2428 */
2529 public function lastModifiedDescriptionsCannotBeEmpty ()
2630 {
27- $ this ->setExpectedException (\ RuntimeException::class);
31+ $ this ->setExpectedException (RuntimeException::class);
2832 $ annotation = new ReplaceWithNotModifiedResponse (['value ' => []]);
2933 $ annotation ->determineLastModified (new Request ());
3034 }
@@ -44,7 +48,7 @@ public function stringAsSimpleLastModifiedDescription()
4448 */
4549 public function serviceNameAsLastModifiedDescription ()
4650 {
47- /** @var ContainerInterface|\ PHPUnit_Framework_MockObject_MockObject $container */
51+ /** @var ContainerInterface|PHPUnit_Framework_MockObject_MockObject $container */
4852 $ container = $ this ->getMock (ContainerInterface::class);
4953 $ container ->expects ($ this ->once ())
5054 ->method ('get ' )
@@ -64,7 +68,7 @@ public function serviceNameAsLastModifiedDescription()
6468 public function arrayAslastModifiedDeterminatorDescriptionWithConstructorArguments ()
6569 {
6670 $ this ->setExpectedException (null );
67- $ annotation = new ReplaceWithNotModifiedResponse (['value ' => [[MyLastModifedDeterminator::class => new \ DateTime ('2000-01-01 ' )]]]);
71+ $ annotation = new ReplaceWithNotModifiedResponse (['value ' => [[MyLastModifedDeterminator::class => new DateTime ('2000-01-01 ' )]]]);
6872 $ annotation ->determineLastModified (new Request ());
6973 }
7074
@@ -73,7 +77,7 @@ public function arrayAslastModifiedDeterminatorDescriptionWithConstructorArgumen
7377 */
7478 public function lastModifiedDeterminatorsHaveToImplementInterface ()
7579 {
76- $ this ->setExpectedException (\ RuntimeException::class);
80+ $ this ->setExpectedException (RuntimeException::class);
7781 $ annotation = new ReplaceWithNotModifiedResponse (['value ' => [FakeLastModifiedDeterminatorWithoutInterface::class]]);
7882 $ annotation ->determineLastModified (new Request ());
7983 }
@@ -85,7 +89,7 @@ public function determineLastModifiedDeterminesLastModifiedOfOneDeterminator()
8589 {
8690 $ annotation = new ReplaceWithNotModifiedResponse (['value ' => [MyLastModifedDeterminator::class]]);
8791 $ this ->assertEquals (
88- new \ DateTime (),
92+ new DateTime (),
8993 $ annotation ->determineLastModified (new Request ()),
9094 '' ,
9195 $ allowedDeltaInSeconds = 3
@@ -98,28 +102,26 @@ public function determineLastModifiedDeterminesLastModifiedOfOneDeterminator()
98102 public function determineLastModifiedDeterminesLastModifiedOfMultipleDeterminators ()
99103 {
100104 $ annotation = new ReplaceWithNotModifiedResponse (['value ' => [
101- [MyLastModifedDeterminator::class => new \ DateTime ('2001-01-01 ' )],
102- [MyLastModifedDeterminator::class => new \ DateTime ('2003-01-01 ' )],
103- [MyLastModifedDeterminator::class => new \ DateTime ('2002-01-01 ' )],
105+ [MyLastModifedDeterminator::class => new DateTime ('2001-01-01 ' )],
106+ [MyLastModifedDeterminator::class => new DateTime ('2003-01-01 ' )],
107+ [MyLastModifedDeterminator::class => new DateTime ('2002-01-01 ' )],
104108 ]]);
105- $ this ->assertEquals (new \ DateTime ('2003-01-01 ' ), $ annotation ->determineLastModified (new Request ()));
109+ $ this ->assertEquals (new DateTime ('2003-01-01 ' ), $ annotation ->determineLastModified (new Request ()));
106110 }
107111}
108112
109-
110-
111113final class FakeLastModifiedDeterminatorWithoutInterface
112114{
113115}
114116
115117final class MyLastModifedDeterminator implements LastModifiedDeterminator
116118{
117- /** @var \ DateTime */
119+ /** @var DateTime */
118120 private $ lastModified ;
119121
120- public function __construct (\ DateTime $ lastModified = null )
122+ public function __construct (DateTime $ lastModified = null )
121123 {
122- $ this ->lastModified = $ lastModified ?: new \ DateTime ();
124+ $ this ->lastModified = $ lastModified ?: new DateTime ();
123125 }
124126
125127 public function getLastModified (Request $ request )
0 commit comments