File tree Expand file tree Collapse file tree 2 files changed +48
-1
lines changed Expand file tree Collapse file tree 2 files changed +48
-1
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,13 @@ protected function getPackageProviders()
1212 return array ('JsLocalization\JsLocalizationServiceProvider ' );
1313 }
1414
15+
16+ public function testProvidesArray () {
17+ $ service = new JsLocalization \JsLocalizationServiceProvider ($ this ->app );
18+
19+ $ this ->assertEquals ( $ service ->provides (), array ('js-localization ' ) );
20+ }
21+
1522 public function testRegisteredNamespaces ()
1623 {
1724 $ this ->assertArrayHasKey (
@@ -44,4 +51,4 @@ public function testBindings ()
4451 $ this ->assertInstanceOf ('JsLocalization\CachingService ' , $ cachingService );
4552 }
4653
47- }
54+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ use Illuminate \Support \Facades \File ;
4+ use JsLocalization \StaticFileResponse ;
5+
6+ class StaticFileResponseTest extends TestCase
7+ {
8+ protected $ testFilePath , $ testFileContent ;
9+
10+ public function setUp ()
11+ {
12+ parent ::setUp ();
13+
14+ $ this ->testFilePath = "/tmp/laravel-static " ;
15+ $ this ->testFileContent = "Test contents! " ;
16+
17+ File::put ($ this ->testFilePath , $ this ->testFileContent );
18+ }
19+
20+ public function testServingFile ()
21+ {
22+ $ response = new StaticFileResponse ($ this ->testFilePath );
23+
24+ $ lastModified = new DateTime ();
25+ $ lastModified ->setTimestamp ( File::lastModified ($ this ->testFilePath ) );
26+
27+ $ this ->assertEquals ($ response ->getStatusCode (), 200 );
28+ $ this ->assertEquals ($ response ->getContent (), $ this ->testFileContent );
29+ $ this ->assertEquals ($ response ->getLastModified ()->getTimestamp (), $ lastModified ->getTimestamp ());
30+ }
31+
32+ public function testExceptionHandling ()
33+ {
34+ $ filePath = "/tmp/x/y/z/does-not-exist " ;
35+ $ this ->setExpectedException ('Exception ' , "Cannot read file: $ filePath " );
36+
37+ $ response = new StaticFileResponse ($ filePath );
38+ }
39+ }
40+ ?>
You can’t perform that action at this time.
0 commit comments