public function testIndex() { $result = ['token1', 'token2']; $this->userManager->expects($this->once())->method('get')->with($this->uid)->will($this->returnValue($this->user)); $this->tokenProvider->expects($this->once())->method('getTokenByUser')->with($this->user)->will($this->returnValue($result)); $this->assertEquals($result, $this->controller->index()); }
public function testIndex() { $token1 = new DefaultToken(); $token1->setId(100); $token2 = new DefaultToken(); $token2->setId(200); $tokens = [$token1, $token2]; $sessionToken = new DefaultToken(); $sessionToken->setId(100); $this->userManager->expects($this->once())->method('get')->with($this->uid)->will($this->returnValue($this->user)); $this->tokenProvider->expects($this->once())->method('getTokenByUser')->with($this->user)->will($this->returnValue($tokens)); $this->session->expects($this->once())->method('getId')->will($this->returnValue('session123')); $this->tokenProvider->expects($this->once())->method('getToken')->with('session123')->will($this->returnValue($sessionToken)); $this->assertEquals([['id' => 100, 'name' => null, 'lastActivity' => null, 'type' => null, 'canDelete' => false], ['id' => 200, 'name' => null, 'lastActivity' => null, 'type' => null, 'canDelete' => true]], $this->controller->index()); }