Implement a better management interface for Settings (#809)
This commit is contained in:
parent
75eb506dab
commit
f9df463d32
40 changed files with 1274 additions and 383 deletions
|
@ -33,16 +33,26 @@ trait RequestMockHelpers
|
|||
}
|
||||
|
||||
/**
|
||||
* Set the active request object to be an instance of a mocked request.
|
||||
* Configure the user model that the request mock should return with.
|
||||
*
|
||||
* @param \Pterodactyl\Models\User|null $user
|
||||
*/
|
||||
protected function buildRequestMock()
|
||||
public function setRequestUserModel(User $user = null)
|
||||
{
|
||||
$this->request = m::mock($this->requestMockClass);
|
||||
if (! $this->request instanceof Request) {
|
||||
throw new InvalidArgumentException('First argument passed to buildRequestMock must be an instance of \Illuminate\Http\Request when mocked.');
|
||||
}
|
||||
$this->request->shouldReceive('user')->andReturn($user);
|
||||
}
|
||||
|
||||
$this->request->attributes = new ParameterBag();
|
||||
/**
|
||||
* Generates a new request user model and also returns the generated model.
|
||||
*
|
||||
* @return \Pterodactyl\Models\User
|
||||
*/
|
||||
public function generateRequestUserModel(): User
|
||||
{
|
||||
$user = factory(User::class)->make();
|
||||
$this->setRequestUserModel($user);
|
||||
|
||||
return $user;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -51,17 +61,41 @@ trait RequestMockHelpers
|
|||
* @param string $attribute
|
||||
* @param mixed $value
|
||||
*/
|
||||
protected function setRequestAttribute(string $attribute, $value)
|
||||
public function setRequestAttribute(string $attribute, $value)
|
||||
{
|
||||
$this->request->attributes->set($attribute, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the request route name.
|
||||
*
|
||||
* @param string $name
|
||||
*/
|
||||
public function setRequestRouteName(string $name)
|
||||
{
|
||||
$this->request->shouldReceive('route->getName')->andReturn($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the active request object to be an instance of a mocked request.
|
||||
*/
|
||||
protected function buildRequestMock()
|
||||
{
|
||||
$this->request = m::mock($this->requestMockClass);
|
||||
if (! $this->request instanceof Request) {
|
||||
throw new InvalidArgumentException('Request mock class must be an instance of ' . Request::class . ' when mocked.');
|
||||
}
|
||||
|
||||
$this->request->attributes = new ParameterBag();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the mocked request user. If a user model is not provided, a factory model
|
||||
* will be created and returned.
|
||||
*
|
||||
* @param \Pterodactyl\Models\User|null $user
|
||||
* @return \Pterodactyl\Models\User
|
||||
* @deprecated
|
||||
*/
|
||||
protected function setRequestUser(User $user = null): User
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue