mirror of
https://github.com/MrUnknownDE/panel.git
synced 2026-04-19 06:43:45 +02:00
Fix database host modification not properly showing SQL errors
This is caused by an old bug relating to not rolling back transactions properly causing session data to not be flashed back to the user properly.
This commit is contained in:
@@ -60,18 +60,20 @@ class HostCreationServiceTest extends TestCase
|
||||
{
|
||||
$model = factory(DatabaseHost::class)->make();
|
||||
|
||||
$this->connection->shouldReceive('beginTransaction')->withNoArgs()->once()->andReturnNull();
|
||||
$this->encrypter->shouldReceive('encrypt')->with('test123')->once()->andReturn('enc123');
|
||||
$this->repository->shouldReceive('create')->with(m::subset([
|
||||
$this->connection->expects('transaction')->with(m::on(function ($closure) {
|
||||
return ! is_null($closure());
|
||||
}))->andReturn($model);
|
||||
|
||||
$this->encrypter->expects('encrypt')->with('test123')->andReturn('enc123');
|
||||
$this->repository->expects('create')->with(m::subset([
|
||||
'password' => 'enc123',
|
||||
'username' => $model->username,
|
||||
'node_id' => $model->node_id,
|
||||
]))->once()->andReturn($model);
|
||||
]))->andReturn($model);
|
||||
|
||||
$this->dynamic->shouldReceive('set')->with('dynamic', $model)->once()->andReturnNull();
|
||||
$this->databaseManager->shouldReceive('connection')->with('dynamic')->once()->andReturnSelf();
|
||||
$this->databaseManager->shouldReceive('select')->with('SELECT 1 FROM dual')->once()->andReturnNull();
|
||||
$this->connection->shouldReceive('commit')->withNoArgs()->once()->andReturnNull();
|
||||
$this->dynamic->expects('set')->with('dynamic', $model)->andReturnNull();
|
||||
$this->databaseManager->expects('connection')->with('dynamic')->andReturnSelf();
|
||||
$this->databaseManager->expects('select')->with('SELECT 1 FROM dual')->andReturnNull();
|
||||
|
||||
$response = $this->getService()->handle([
|
||||
'password' => 'test123',
|
||||
|
||||
@@ -60,14 +60,15 @@ class HostUpdateServiceTest extends TestCase
|
||||
{
|
||||
$model = factory(DatabaseHost::class)->make();
|
||||
|
||||
$this->encrypter->shouldReceive('encrypt')->with('test123')->once()->andReturn('enc123');
|
||||
$this->connection->shouldReceive('beginTransaction')->withNoArgs()->once()->andReturnNull();
|
||||
$this->repository->shouldReceive('update')->with(1234, ['password' => 'enc123'])->once()->andReturn($model);
|
||||
$this->connection->expects('transaction')->with(m::on(function ($closure) {
|
||||
return ! is_null($closure());
|
||||
}))->andReturn($model);
|
||||
|
||||
$this->dynamic->shouldReceive('set')->with('dynamic', $model)->once()->andReturnNull();
|
||||
$this->databaseManager->shouldReceive('connection')->with('dynamic')->once()->andReturnSelf();
|
||||
$this->databaseManager->shouldReceive('select')->with('SELECT 1 FROM dual')->once()->andReturnNull();
|
||||
$this->connection->shouldReceive('commit')->withNoArgs()->once()->andReturnNull();
|
||||
$this->encrypter->expects('encrypt')->with('test123')->andReturn('enc123');
|
||||
$this->repository->expects('update')->with(1234, ['password' => 'enc123'])->andReturn($model);
|
||||
$this->dynamic->expects('set')->with('dynamic', $model)->andReturnNull();
|
||||
$this->databaseManager->expects('connection')->with('dynamic')->andReturnSelf();
|
||||
$this->databaseManager->expects('select')->with('SELECT 1 FROM dual')->andReturnNull();
|
||||
|
||||
$response = $this->getService()->handle(1234, ['password' => 'test123']);
|
||||
$this->assertNotEmpty($response);
|
||||
@@ -81,13 +82,14 @@ class HostUpdateServiceTest extends TestCase
|
||||
{
|
||||
$model = factory(DatabaseHost::class)->make();
|
||||
|
||||
$this->connection->shouldReceive('beginTransaction')->withNoArgs()->once()->andReturnNull();
|
||||
$this->repository->shouldReceive('update')->with(1234, ['username' => 'test'])->once()->andReturn($model);
|
||||
$this->connection->expects('transaction')->with(m::on(function ($closure) {
|
||||
return ! is_null($closure());
|
||||
}))->andReturn($model);
|
||||
|
||||
$this->dynamic->shouldReceive('set')->with('dynamic', $model)->once()->andReturnNull();
|
||||
$this->databaseManager->shouldReceive('connection')->with('dynamic')->once()->andReturnSelf();
|
||||
$this->databaseManager->shouldReceive('select')->with('SELECT 1 FROM dual')->once()->andReturnNull();
|
||||
$this->connection->shouldReceive('commit')->withNoArgs()->once()->andReturnNull();
|
||||
$this->repository->expects('update')->with(1234, ['username' => 'test'])->andReturn($model);
|
||||
$this->dynamic->expects('set')->with('dynamic', $model)->andReturnNull();
|
||||
$this->databaseManager->expects('connection')->with('dynamic')->andReturnSelf();
|
||||
$this->databaseManager->expects('select')->with('SELECT 1 FROM dual')->andReturnNull();
|
||||
|
||||
$response = $this->getService()->handle(1234, ['password' => '', 'username' => 'test']);
|
||||
$this->assertNotEmpty($response);
|
||||
|
||||
Reference in New Issue
Block a user