Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 229 #272

Merged
merged 22 commits into from
Apr 9, 2019
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
2054625
Block Preview styling
boehsermoe Nov 9, 2018
fcd0e42
Tooltip preview fix #246
boehsermoe Nov 13, 2018
715cab9
Merge branch 'master' of https://github.com/luyadev/luya-module-admin
boehsermoe Nov 22, 2018
572faf5
Merge branch 'master' of https://github.com/luyadev/luya-module-admin
boehsermoe Nov 26, 2018
082c9f6
Merge branch 'master' of github.com:boehsermoe/luya-module-admin
boehsermoe Jan 28, 2019
f775595
Merge branch 'master' of github.com:boehsermoe/luya-module-admin
boehsermoe Mar 4, 2019
d66099e
Date plugin with custom format
boehsermoe Mar 4, 2019
5aeeea8
Changelog for #270
boehsermoe Mar 5, 2019
13c52e2
Refactored namespace using
boehsermoe Mar 5, 2019
933ece9
Unittest for proxy sync with sql error close #229
boehsermoe Mar 5, 2019
5d45200
Merge branch 'master' of https://github.com/luyadev/luya-module-admin
boehsermoe Mar 5, 2019
f3a2b50
Merge branch 'master' into issue-229
boehsermoe Mar 5, 2019
3e83e46
Update ClientTable.php
boehsermoe Mar 14, 2019
d8fd0fc
Refactoring
boehsermoe Mar 14, 2019
6f64e45
Merge branch 'issue-229' of github.com:boehsermoe/luya-module-admin i…
boehsermoe Mar 14, 2019
e7c206d
Refactoring
boehsermoe Mar 14, 2019
d2bda67
UnitTest notice exception
boehsermoe Mar 14, 2019
98ac455
Unit test fiexed
boehsermoe Mar 28, 2019
7caabc2
Unit test fixed
boehsermoe Apr 9, 2019
26f06e7
Unit test expected excaption message
boehsermoe Apr 9, 2019
a0ac75b
Unit test expected excaption message
boehsermoe Apr 9, 2019
a610c05
Unit test expected exception message
boehsermoe Apr 9, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/proxy/ClientBuild.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,10 @@ public function getStorageFilesCount()
}

private $_tables = [];


/**
* @return ClientTable[]
*/
public function getTables()
{
return $this->_tables;
Expand Down
6 changes: 4 additions & 2 deletions src/proxy/ClientTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
namespace luya\admin\proxy;

use Curl\Curl;
use Symfony\Component\Debug\Exception\UndefinedMethodException;
boehsermoe marked this conversation as resolved.
Show resolved Hide resolved
use Yii;
use yii\base\BaseObject;
use yii\db\Exception;
boehsermoe marked this conversation as resolved.
Show resolved Hide resolved
use yii\helpers\Console;
use yii\helpers\Json;

Expand Down Expand Up @@ -149,7 +151,7 @@ public function syncData()
* @throws \yii\db\Exception
* @since 1.2.1
*/
private function prepare()
protected function prepare()
{
$sqlMode = null;

Expand All @@ -175,7 +177,7 @@ private function prepare()
* @throws \yii\db\Exception
* @since 1.2.1
*/
private function cleanup($sqlMode)
protected function cleanup($sqlMode)
{
if (Yii::$app->db->schema instanceof \yii\db\mysql\Schema) {
Yii::$app->db->createCommand('SET FOREIGN_KEY_CHECKS = 1;')->execute();
Expand Down
34 changes: 34 additions & 0 deletions tests/admin/proxy/ClientTableTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

namespace admintests\admin\proxy;

use admintests\AdminTestCase;
use admintests\data\mocks\proxy\ClientTableMock;
use luya\admin\proxy\ClientBuild;
use luya\admin\proxy\ClientTable;
use luya\admin\commands\ProxyController;

class ClientTableTest extends AdminTestCase
{
/**
* @throws \yii\db\Exception
* @expectedException \yii\db\Exception
*/
public function testSyncDataWithConnectionLost()
{
$this->app->db->createCommand('CREATE TABLE IF NOT EXISTS temp_synctest LIKE admin_user')->execute();

$ctrl = new ProxyController('proxyctrl', $this->app);
$build = new ClientBuild($ctrl, [
'buildConfig' => ['tables' => ['temp_synctest' => ['name' => 'temp_synctest']]],
]);
$table = new ClientTableMock($build, ['name' => 'temp_synctest']);

try {
$table->syncData();
nadar marked this conversation as resolved.
Show resolved Hide resolved
} catch (\yii\db\Exception $exception) {
$this->assertEquals('PDOStatement::execute(): MySQL server has gone away', $exception->getPrevious()->getMessage());
throw $exception;
}
}
}
22 changes: 22 additions & 0 deletions tests/data/mocks/proxy/ClientTableMock.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

namespace admintests\data\mocks\proxy;

use luya\admin\proxy\ClientTable;
use Yii;

class ClientTableMock extends ClientTable
{
protected function cleanup($sqlMode)
{
try {
// provoke sql error on later cleanup
Yii::$app->db->createCommand('KILL (SELECT CONNECTION_ID());')->execute();
} catch (\Throwable $ex) {

}

parent::cleanup($sqlMode);
}

}