public function testUpdateExistingRoleReturnsError() { $roles = Woodling::savedList('Role', 3); $response = $this->call('PUT', '/api/roles/' . $roles[2]->id, ['name' => $roles[1]->name]); $data = $this->assertResponse($response, 403); $this->assertContains('taken', $data->errors[0]); }
public function testStaticSavedListWithOverrides() { $name = 'stdClass'; $count = 3; $overrides = array('name' => 'Mindaugas Bujanauskas'); $returnValue = new $name(); $coreMock = $this->getMock('Woodling\\Core', array('savedList')); $coreMock->expects($this->once())->method('savedList')->with($this->equalTo($name), $this->equalTo($count), $this->equalTo($overrides))->will($this->returnValue($returnValue)); Woodling::core($coreMock); $list = Woodling::savedList($name, $count, $overrides); $this->assertEquals($returnValue, $list); }
public function testAdminDeleteUserCleansAssignedRoles() { $admin = $this->helperCreateUserAndLogin('admin'); $user = Woodling::saved('User'); $roles = Woodling::savedList('Role', 3); $this->call('PUT', '/api/users/' . $user->id, ['roles' => $roles]); $response = $this->call('DELETE', '/api/users/' . $user->id); $assigned = DB::table('assigned_roles')->where('user_id', $user->id)->get(); $this->assertEquals(0, count($assigned)); }
public function testAdminReadUserShowAllFields() { Woodling::savedList('User', 3); $admin = $this->helperCreateUserAndLogin('admin'); $response = $this->call('GET', '/api/users'); $data = $this->assertResponse($response); $this->assertNotEmpty('email', $data[0]->email); $this->assertNotEmpty('status', $data[0]->status); }