public function testSelfChangeUserPassword()
{
$builtinProvider = $this->getContainer()->get('partkeepr.userservice')->getBuiltinProvider();
$user = new User('bernd2');
$user->setPassword(md5('admin'));
$user->setLegacy(true);
$user->setProvider($builtinProvider);
$this->getContainer()->get('doctrine.orm.default_entity_manager')->persist($user);
$this->getContainer()->get('doctrine.orm.default_entity_manager')->flush($user);
$client = static::makeClient(false, ['PHP_AUTH_USER' => 'bernd2', 'PHP_AUTH_PW' => 'admin']);
$iriConverter = $this->getContainer()->get('api.iri_converter');
$iri = $iriConverter->getIriFromItem($user) . '/changePassword';
$parameters = ['oldpassword' => 'admin', 'newpassword' => 'foobar'];
$client->request('PUT', $iri, $parameters);
$response = json_decode($client->getResponse()->getContent());
$this->assertEquals(200, $client->getResponse()->getStatusCode());
$this->assertFalse($response->{'legacy'});
$this->assertEmpty($response->{'password'});
$this->assertEmpty($response->{'newPassword'});
$client = static::makeClient(false, ['PHP_AUTH_USER' => 'bernd2', 'PHP_AUTH_PW' => 'foobar']);
$client->request('PUT', $iri, $parameters);
$response = json_decode($client->getResponse()->getContent());
$this->assertEquals(500, $client->getResponse()->getStatusCode());
$this->assertObjectHasAttribute('@type', $response);
$this->assertEquals('Error', $response->{'@type'});
}