Update repository base code to be cleaner and make use of PHP 7 features

This commit is contained in:
Dane Everitt 2018-01-04 22:49:50 -06:00
parent 0ec5a4e08c
commit 60eb60013c
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
96 changed files with 1048 additions and 1785 deletions

View file

@ -1,11 +1,4 @@
<?php
/**
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
*
* This software is licensed under the terms of the MIT license.
* https://opensource.org/licenses/MIT
*/
namespace Tests\Unit\Commands\User;
@ -60,7 +53,7 @@ class DeleteUserCommandTest extends CommandTestCase
$user2 = factory(User::class)->make(),
]);
$this->repository->shouldReceive('search')->with($user1->username)->once()->andReturnSelf()
$this->repository->shouldReceive('setSearchTerm')->with($user1->username)->once()->andReturnSelf()
->shouldReceive('all')->withNoArgs()->once()->andReturn($users);
$this->deletionService->shouldReceive('handle')->with($user1->id)->once()->andReturnNull();
@ -82,9 +75,9 @@ class DeleteUserCommandTest extends CommandTestCase
$user1 = factory(User::class)->make(),
]);
$this->repository->shouldReceive('search')->with('noResults')->once()->andReturnSelf()
->shouldReceive('all')->withNoArgs()->once()->andReturn([]);
$this->repository->shouldReceive('search')->with($user1->username)->once()->andReturnSelf()
$this->repository->shouldReceive('setSearchTerm')->with('noResults')->once()->andReturnSelf()
->shouldReceive('all')->withNoArgs()->once()->andReturn(collect());
$this->repository->shouldReceive('setSearchTerm')->with($user1->username)->once()->andReturnSelf()
->shouldReceive('all')->withNoArgs()->once()->andReturn($users);
$this->deletionService->shouldReceive('handle')->with($user1->id)->once()->andReturnNull();
@ -107,7 +100,7 @@ class DeleteUserCommandTest extends CommandTestCase
$user1 = factory(User::class)->make(),
]);
$this->repository->shouldReceive('search')->with($user1->username)->twice()->andReturnSelf()
$this->repository->shouldReceive('setSearchTerm')->with($user1->username)->twice()->andReturnSelf()
->shouldReceive('all')->withNoArgs()->twice()->andReturn($users);
$this->deletionService->shouldReceive('handle')->with($user1->id)->once()->andReturnNull();
@ -130,7 +123,7 @@ class DeleteUserCommandTest extends CommandTestCase
$user1 = factory(User::class)->make(),
]);
$this->repository->shouldReceive('search')->with($user1->username)->once()->andReturnSelf()
$this->repository->shouldReceive('setSearchTerm')->with($user1->username)->once()->andReturnSelf()
->shouldReceive('all')->withNoArgs()->once()->andReturn($users);
$this->deletionService->shouldNotReceive('handle');
@ -149,7 +142,7 @@ class DeleteUserCommandTest extends CommandTestCase
$user1 = factory(User::class)->make(),
]);
$this->repository->shouldReceive('search')->with($user1->username)->once()->andReturnSelf()
$this->repository->shouldReceive('setSearchTerm')->with($user1->username)->once()->andReturnSelf()
->shouldReceive('all')->withNoArgs()->once()->andReturn($users);
$this->deletionService->shouldReceive('handle')->with($user1)->once()->andReturnNull();
@ -169,7 +162,7 @@ class DeleteUserCommandTest extends CommandTestCase
$user2 = factory(User::class)->make(),
]);
$this->repository->shouldReceive('search')->with($user1->username)->once()->andReturnSelf()
$this->repository->shouldReceive('setSearchTerm')->with($user1->username)->once()->andReturnSelf()
->shouldReceive('all')->withNoArgs()->once()->andReturn($users);
$this->deletionService->shouldNotReceive('handle');
@ -184,8 +177,8 @@ class DeleteUserCommandTest extends CommandTestCase
*/
public function testNoInteractionWithNoResults()
{
$this->repository->shouldReceive('search')->with(123456)->once()->andReturnSelf()
->shouldReceive('all')->withNoArgs()->once()->andReturn([]);
$this->repository->shouldReceive('setSearchTerm')->with(123456)->once()->andReturnSelf()
->shouldReceive('all')->withNoArgs()->once()->andReturn(collect());
$display = $this->withoutInteraction()->runCommand($this->command, ['--user' => 123456]);

View file

@ -47,7 +47,7 @@ class DisableTwoFactorCommandTest extends CommandTestCase
{
$user = factory(User::class)->make();
$this->repository->shouldReceive('withColumns')->with(['id', 'email'])->once()->andReturnSelf()
$this->repository->shouldReceive('setColumns')->with(['id', 'email'])->once()->andReturnSelf()
->shouldReceive('findFirstWhere')->with([['email', '=', $user->email]])->once()->andReturn($user);
$this->repository->shouldReceive('withoutFresh')->withNoArgs()->once()->andReturnSelf()
->shouldReceive('update')->with($user->id, [
@ -68,7 +68,7 @@ class DisableTwoFactorCommandTest extends CommandTestCase
{
$user = factory(User::class)->make();
$this->repository->shouldReceive('withColumns')->with(['id', 'email'])->once()->andReturnSelf()
$this->repository->shouldReceive('setColumns')->with(['id', 'email'])->once()->andReturnSelf()
->shouldReceive('findFirstWhere')->with([['email', '=', $user->email]])->once()->andReturn($user);
$this->repository->shouldReceive('withoutFresh')->withNoArgs()->once()->andReturnSelf()
->shouldReceive('update')->with($user->id, [