ChainEventTest.php 1.34 KB
Newer Older
1
2
3
4
<?php
namespace UnicaenAuthTest\Authentication\Storage;

use PDOException;
5
use PHPUnit\Framework\TestCase;
6
7
8
9
10
11
12
13
14
15
use UnicaenAuth\Authentication\Storage\Db;
use Zend\ServiceManager\Exception\ServiceNotFoundException;
use ZfcUser\Entity\User;
use UnicaenAuth\Authentication\Storage\ChainEvent;

/**
 * Description of ChainEventTest
 *
 * @author Bertrand GAUTHIER <bertrand.gauthier at unicaen.fr>
 */
16
class ChainEventTest extends TestCase
17
18
{
    protected $event;
19

20
21
22
23
24
25
26
27
    /**
     * Sets up the fixture, for example, open a network connection.
     * This method is called before a test is executed.
     */
    protected function setUp()
    {
        $this->event = new ChainEvent();
    }
28

29
30
    public function testContentsIsEmptyAtConstruction()
    {
31
        $this->assertEquals([], $this->event->getContents());
32
    }
33

34
35
36
37
    public function testCanAddContents()
    {
        $this->event->addContents('key 1', 'content 1');
        $this->event->addContents('key 2', 'content 2');
38
39
        $expected = [
            'key 1' => 'content 1',
40
            'key 2' => 'content 2',
41
        ];
42
43
        $this->assertEquals($expected, $this->event->getContents());
    }
44

45
46
47
48
    public function testCanClearContents()
    {
        $this->event->addContents('key 1', 'content 1.1');
        $this->event->clearContents();
49
        $this->assertEquals([], $this->event->getContents());
50
51
    }
}