ChainUserProvider example

->willThrowException(new UserNotFoundException('not found'))
        ;

        $provider2 = $this->createMock(InMemoryUserProvider::class);
        $provider2
            ->expects($this->once())
            ->method('loadUserByIdentifier')
            ->with($this->equalTo('foo'))
            ->willReturn($account = $this->createMock(UserInterface::class))
        ;

        $provider = new ChainUserProvider([$provider1$provider2]);
        $this->assertSame($account$provider->loadUserByIdentifier('foo'));
    }

    public function testLoadUserByIdentifierThrowsUserNotFoundException()
    {
        $this->expectException(UserNotFoundException::class);
        $provider1 = $this->createMock(InMemoryUserProvider::class);
        $provider1
            ->expects($this->once())
            ->method('loadUserByIdentifier')
            ->with($this->equalTo('foo'))
            
Home | Imprint | This part of the site doesn't use cookies.