public function testPrepare() { $u = new User($this->container); $input = array('username' => 'user1', 'password' => '1234', 'confirmation' => '1234', 'name' => 'me', 'role' => Role::APP_ADMIN); $u->prepare($input); $this->assertArrayNotHasKey('confirmation', $input); $this->assertArrayHasKey('password', $input); $this->assertNotEquals('1234', $input['password']); $this->assertNotEmpty($input['password']); $input = array('username' => 'user1', 'password' => '1234', 'current_password' => 'bla', 'confirmation' => '1234', 'name' => 'me', 'is_ldap_user' => '1'); $u->prepare($input); $this->assertArrayNotHasKey('confirmation', $input); $this->assertArrayNotHasKey('current_password', $input); $this->assertArrayHasKey('password', $input); $this->assertNotEquals('1234', $input['password']); $this->assertNotEmpty($input['password']); $this->assertArrayHasKey('is_ldap_user', $input); $this->assertEquals(1, $input['is_ldap_user']); $input = array('id' => 2, 'name' => 'me'); $u->prepare($input); $this->assertEquals(array('id' => 2, 'name' => 'me'), $input); $input = array('gitlab_id' => '1234'); $u->prepare($input); $this->assertEquals(array('gitlab_id' => 1234), $input); $input = array('gitlab_id' => ''); $u->prepare($input); $this->assertEquals(array('gitlab_id' => null), $input); $input = array('gitlab_id' => 'something'); $u->prepare($input); $this->assertEquals(array('gitlab_id' => 0), $input); $input = array('username' => 'something', 'password' => ''); $u->prepare($input); $this->assertEquals(array('username' => 'something'), $input); }