Beispiel #1
0
    public function testSetParameters()
    {
        $userContext = new UserContext();

        $userContext->addParameter('authenticated', true);
        $userContext->setParameters(array(
            'roles' => array('ROLE_USER'),
            'foo' => 'bar'
        ));

        $this->assertFalse($userContext->hasParameter('authenticated'));
        $this->assertTrue($userContext->hasParameter('foo'));
        $this->assertTrue($userContext->hasParameter('roles'));

        $parameters = array();
        foreach ($userContext as $name => $value) {
            $parameters[$name] = $value;
        }
        $this->assertEquals(
            array('roles' => array('ROLE_USER'), 'foo' => 'bar'),
            $parameters
        );
    }