Beispiel #1
0
 /**
  * Test UserServiceContract::createUser(array $user, array $roles).
  *
  * @return void
  */
 public function testUpdateUserWithRoles()
 {
     $mockRoles = [UserRole::ADMIN, UserRole::MEMBER];
     $mockUser = $this->getMockAdmin();
     $mockUpdateData = $mockUser->toArray();
     unset($mockUpdateData['roles']);
     $mockRepository = $this->getMockUserRepository();
     $mockRepository->shouldReceive('update')->once()->with($mockUser, $mockUpdateData)->andReturn($mockUser);
     $mockRepository->shouldReceive('syncRoles')->once()->with($mockUser, $mockRoles)->andReturn($mockUser);
     $service = new UserService($mockRepository);
     $user = $service->updateUser($mockUser, $mockUpdateData, $mockRoles);
     $this->assertEquals($user, $mockUser, 'updateUser(User $user, array $update, array $roles) returned an invalid result');
 }