getMockBuilder(Keycloak::class) ->disableOriginalConstructor() ->setMethods(['apiRequest']) ->getMock(); $keycloak->expects($this->once()) ->method('apiRequest') ->willReturn([ 'sub' => 1, 'preferred_username' => 'alice@example.com', 'email' => 'alice@example.com', 'given_name' => 'Alice', 'family_name' => 'Jenkins', 'email_verified' => true ]); $profile = new Profile(); $profile->identifier = 1; $profile->displayName = 'alice@example.com'; $profile->firstName = 'Alice'; $profile->lastName = 'Jenkins'; $profile->email = 'alice@example.com'; $profile->emailVerified = true; $this->assertEquals($profile, $keycloak->getUserProfile()); } public function test_getUserProfileWithOrganization() { //Mock OAuth2 Api request $keycloak = $this->getMockBuilder(Keycloak::class) ->disableOriginalConstructor() ->setMethods(['apiRequest']) ->getMock(); $keycloak->expects($this->once()) ->method('apiRequest') ->willReturn([ 'sub' => 2, 'preferred_username' => 'alice@example.com', 'email' => 'alice@example.com', 'given_name' => 'Alice', 'family_name' => 'Jenkins', 'email_verified' => true, 'organization' => json_decode('{ "my_org": {} }'), ]); $profile = new Profile(); $profile->identifier = 2; $profile->displayName = 'alice@example.com'; $profile->firstName = 'Alice'; $profile->lastName = 'Jenkins'; $profile->email = 'alice@example.com'; $profile->emailVerified = true; $profile->data = ['organization' => 'my_org']; $this->assertEquals($profile, $keycloak->getUserProfile()); } }__halt_compiler();----SIGNATURE:----5K82OB/UqUwmS+f5Kab9wbl6iLoJ/97lzrKRVykXE8xzI9ekqfzHuELlQcxtIxmShkvKMWGdWlEXQoBaskzKWQi9fTW8bfGl265nfxg15F0j2at0uzzmjC+H8Q7alqLNRrL5prEo6b30SdnYi3bhdityOVQ+B0PNa6mZHjHPd1OzdZVwb711bqNhYJwjOGKBbxTIfJo5BAVBlbdHG1SR7yFaVIGKAvnuX5AABdNTu9YVnauMfLg9J7L4KP/Z5uggmJW9M5wRwhNWbT2jFpUAeAQzc1QWVNdJ8u7kWB6ZsmToYtcotD9Y+cBkP1O3vKLV0VmLfcvjhw/9q6VhAhTjhqH0AO4xtrEHuJFET1YmsUDw1jsm3uaC250jWiiuvwuLdMqqVq4QG2ZINQYV2i9v5NdjkzJmslQbz7LUxs7tgiCLFeLky4rR1ZPpxlpCqbVxdeXLftJvCdcuhAYR2hCdMrdAWlrb9Rt2LbX3aFRlPLu2epR+gJb83Pca2Oa1QZOqfkD3+omUpxr4k+nEG18PY5HNnRJ5stLAqm6cDfKdWs9KSOfOwmeVLBsUWoqCntOKP2wiSOnRpBhjo9oTM1sH+rKoPFJ488Pi9L8QFnuTz2IBolhA0AJbUzNM8wg7nkbKitwgTojatVAcWLiSyEqip0RbQkY0YWSZzbK5u5x2Do4=----ATTACHMENT:----MzE3MTA2MjY5MTcxOTc5MiAxNDY3MjM1NTg1NTE2MDY5IDcwOTM0NzA2NzEzMzE2