コード例 #1
0
ファイル: GroupControllerTest.php プロジェクト: ollietb/sulu
 public function testPut()
 {
     $client = $this->createAuthenticatedClient();
     $client->request('PUT', '/api/groups/' . $this->group1->getId(), ['name' => 'Updated Group1', 'parent' => ['id' => $this->group2->getId()], 'roles' => [['id' => $this->role1->getId()]]]);
     $response = json_decode($client->getResponse()->getContent());
     $this->assertEquals('Updated Group1', $response->name);
     $this->assertEquals($this->group2->getId(), $response->parent->id);
     $this->assertCount(1, $response->roles);
     $this->assertEquals('Sulu Administrator', $response->roles[0]->name);
     $client->request('GET', '/api/groups/' . $this->group1->getId());
     $this->assertEquals('Updated Group1', $response->name);
     $this->assertEquals($this->group2->getId(), $response->parent->id);
     $this->assertCount(1, $response->roles);
     $this->assertEquals('Sulu Administrator', $response->roles[0]->name);
 }
コード例 #2
0
 public function testPutWithEmptyPassword()
 {
     $client = $this->createAuthenticatedClient();
     $client->request('PUT', '/api/users/' . $this->user1->getId(), ['username' => 'manager', 'password' => '', 'locale' => 'en', 'contact' => ['id' => $this->contact1->getId()], 'userRoles' => [['id' => $this->user1->getId(), 'role' => ['id' => $this->role1->getId()], 'locales' => ['de', 'en']], ['id' => 2, 'role' => ['id' => $this->role2->getId()], 'locales' => ['en']]]]);
     $response = json_decode($client->getResponse()->getContent());
     $this->assertEquals('manager', $response->username);
     $this->assertEquals('securepassword', $response->password);
     $this->assertEquals($this->contact1->getId(), $response->contact->id);
     $this->assertEquals('en', $response->locale);
     $this->assertEquals('Role1', $response->userRoles[0]->role->name);
     $this->assertEquals('de', $response->userRoles[0]->locales[0]);
     $this->assertEquals('en', $response->userRoles[0]->locales[1]);
     $this->assertEquals('Role2', $response->userRoles[1]->role->name);
     $this->assertEquals('en', $response->userRoles[1]->locales[0]);
     $refreshedUser = $this->em->getRepository('SuluSecurityBundle:User')->find($this->user1->getId());
     $this->assertEquals($this->user1->getSalt(), $refreshedUser->getSalt());
 }