File tree Expand file tree Collapse file tree 4 files changed +41
-1
lines changed Expand file tree Collapse file tree 4 files changed +41
-1
lines changed Original file line number Diff line number Diff line change 2
2
3
3
## Unreleased
4
4
5
+ ## 0.4.1 - 2021-05-23
6
+
7
+ ### Added
8
+ - Ability to override the environment.
9
+
5
10
## 0.4.0 - 2021-05-23
6
11
7
12
### Added
Original file line number Diff line number Diff line change @@ -111,7 +111,7 @@ protected function potentiallyThrowRequestException($response)
111
111
112
112
protected function throwUnlessProduction ($ exception )
113
113
{
114
- throw_unless (app ()-> environment ('production ' ) , $ exception );
114
+ throw_unless (Torchlight:: environment () === 'production ' , $ exception );
115
115
}
116
116
117
117
public function cachePrefix ()
Original file line number Diff line number Diff line change @@ -31,6 +31,11 @@ class Manager
31
31
*/
32
32
protected $ app ;
33
33
34
+ /**
35
+ * @var null|string
36
+ */
37
+ protected $ environment ;
38
+
34
39
/**
35
40
* @param Container $app
36
41
*/
@@ -56,6 +61,22 @@ public function client()
56
61
return $ this ->app ->make (Client::class);
57
62
}
58
63
64
+ /**
65
+ * @return string
66
+ */
67
+ public function environment ()
68
+ {
69
+ return $ this ->environment ?? app ()->environment ();
70
+ }
71
+
72
+ /**
73
+ * @param string $environment
74
+ */
75
+ public function overrideEnvironment ($ environment = null )
76
+ {
77
+ $ this ->environment = $ environment ;
78
+ }
79
+
59
80
/**
60
81
* Get an item out of the config using dot notation.
61
82
*
Original file line number Diff line number Diff line change @@ -60,4 +60,18 @@ public function cache_implementation_can_be_set()
60
60
$ this ->assertFalse ($ newStore ->has ('original_key ' ));
61
61
$ this ->assertTrue ($ newStore ->has ('new_key ' ));
62
62
}
63
+
64
+ /** @test */
65
+ public function environment_can_be_set ()
66
+ {
67
+ $ this ->assertEquals ('testing ' , Torchlight::environment ());
68
+
69
+ Torchlight::overrideEnvironment ('production ' );
70
+
71
+ $ this ->assertEquals ('production ' , Torchlight::environment ());
72
+
73
+ Torchlight::overrideEnvironment (null );
74
+
75
+ $ this ->assertEquals ('testing ' , Torchlight::environment ());
76
+ }
63
77
}
You can’t perform that action at this time.
0 commit comments