Subversion-Projekte lars-tiefland.laravel_shop

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
148 lars 1
<?php
2
 
3
namespace Illuminate\Foundation\Testing\Concerns;
4
 
5
trait InteractsWithSession
6
{
7
    /**
8
     * Set the session to the given array.
9
     *
10
     * @param  array  $data
11
     * @return $this
12
     */
13
    public function withSession(array $data)
14
    {
15
        $this->session($data);
16
 
17
        return $this;
18
    }
19
 
20
    /**
21
     * Set the session to the given array.
22
     *
23
     * @param  array  $data
24
     * @return $this
25
     */
26
    public function session(array $data)
27
    {
28
        $this->startSession();
29
 
30
        foreach ($data as $key => $value) {
31
            $this->app['session']->put($key, $value);
32
        }
33
 
34
        return $this;
35
    }
36
 
37
    /**
38
     * Start the session for the application.
39
     *
40
     * @return $this
41
     */
42
    protected function startSession()
43
    {
44
        if (! $this->app['session']->isStarted()) {
45
            $this->app['session']->start();
46
        }
47
 
48
        return $this;
49
    }
50
 
51
    /**
52
     * Flush all of the current session data.
53
     *
54
     * @return $this
55
     */
56
    public function flushSession()
57
    {
58
        $this->startSession();
59
 
60
        $this->app['session']->flush();
61
 
62
        return $this;
63
    }
64
}