-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
/
Copy pathSessionCollectorTest.php
40 lines (31 loc) · 1.27 KB
/
SessionCollectorTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
namespace Barryvdh\Debugbar\Tests\DataCollector;
use Barryvdh\Debugbar\Tests\TestCase;
use Barryvdh\Debugbar\DataCollector\SessionCollector;
use Illuminate\Session\SessionManager;
class SessionCollectorTest extends TestCase
{
protected function getEnvironmentSetUp($app)
{
$app['config']->set('debugbar.options.session.hiddens', ['secret']);
parent::getEnvironmentSetUp($app);
}
public function testItCollectsSessionVariables()
{
/** @var \Barryvdh\Debugbar\DataCollector\SessionCollector $collector */
$collector = new SessionCollector(
$this->app->make(SessionManager::class),
$this->app['config']->get('debugbar.options.session.hiddens', [])
);
$this->assertEmpty($collector->collect());
$this->withSession(['testVariable' => 1, 'secret' => 'testSecret'])->get('/');
$collected = $collector->collect();
$this->assertNotEmpty($collected);
$this->assertArrayHasKey('secret', $collected);
$this->assertArrayHasKey('testVariable', $collected);
$this->assertEquals($collected['secret'], '******');
$this->assertEquals($collected['testVariable'], 1);
$this->flushSession();
$this->assertCount(0, $collector->collect());
}
}