-
Notifications
You must be signed in to change notification settings - Fork 297
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[1.x] Flushes
Str
cache between requests (#468)
* Flushes `Str` cache between requests * Bumps framework version
- Loading branch information
1 parent
1e06328
commit 3c4e717
Showing
4 changed files
with
60 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
namespace Laravel\Octane\Listeners; | ||
|
||
use Illuminate\Support\Str; | ||
|
||
class FlushStrCache | ||
{ | ||
/** | ||
* Handle the event. | ||
* | ||
* @param mixed $event | ||
* @return void | ||
*/ | ||
public function handle($event) | ||
{ | ||
Str::flushCache(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
namespace Laravel\Octane\Listeners; | ||
|
||
use Illuminate\Http\Request; | ||
use Illuminate\Support\Str; | ||
use Laravel\Octane\Tests\TestCase; | ||
use ReflectionClass; | ||
|
||
class FlushStrCacheTest extends TestCase | ||
{ | ||
public function test_str_is_flushed() | ||
{ | ||
Str::flushCache(); | ||
|
||
[$app, $worker, $client] = $this->createOctaneContext([ | ||
Request::create('/test-str-cache', 'GET'), | ||
Request::create('/', 'GET'), | ||
]); | ||
|
||
$app['router']->middleware('web')->get('/', function () { | ||
return 'Hello World'; | ||
}); | ||
|
||
$app['router']->middleware('web')->get('/test-str-cache', function () { | ||
return Str::snake('Taylor Otwell'); | ||
}); | ||
|
||
$reflection = new ReflectionClass(Str::class); | ||
$property = $reflection->getProperty('snakeCache'); | ||
$property->setAccessible(true); | ||
|
||
$this->assertEmpty($property->getValue()); | ||
|
||
$worker->run(); | ||
|
||
$this->assertEmpty($property->getValue()); | ||
} | ||
} |