From a29400722fea9181f06f4044df8affbef7e70c3c Mon Sep 17 00:00:00 2001 From: Dario Rekowski on RockPI Date: Fri, 28 May 2021 11:10:04 +0000 Subject: [PATCH] fix another one --- .../src/Controller/AppController.php | 17 +------ .../tests/Fixture/Migrations2Fixture.php | 45 ++++++++++++++++++ .../TestCase/Controller/AppControllerTest.php | 46 ------------------- .../JsonRequestClientComponentTest.php | 14 +----- .../Controller/PagesControllerTest.php | 16 +++++-- 5 files changed, 59 insertions(+), 79 deletions(-) create mode 100644 community_server/tests/Fixture/Migrations2Fixture.php delete mode 100644 community_server/tests/TestCase/Controller/AppControllerTest.php diff --git a/community_server/src/Controller/AppController.php b/community_server/src/Controller/AppController.php index a1416678f..eb11299ce 100644 --- a/community_server/src/Controller/AppController.php +++ b/community_server/src/Controller/AppController.php @@ -88,19 +88,8 @@ class AppController extends Controller // load current balance $session = $this->getRequest()->getSession(); $state_user_id = $session->read('StateUser.id'); - if ($state_user_id) { - $stateBalancesTable = TableRegistry::getTableLocator()->get('stateBalances'); - $stateBalanceQuery = $stateBalancesTable - ->find('all') - ->contain(false) - ->where(['state_user_id' => $state_user_id]); - if ($stateBalanceQuery->count() == 1) { - //var_dump($stateBalanceEntry->first()); - $session->write('StateUser.balance', $stateBalanceQuery->first()->decay); - //echo "stateUser.balance: " . $session->read('StateUser.balance'); - } - } - + + // load error count if ($state_user_id) { $stateErrorsTable = TableRegistry::getTableLocator()->get('stateErrors'); @@ -111,8 +100,6 @@ class AppController extends Controller ->where(['state_user_id' => $state_user_id]); $session->write('StateUser.errorCount', $stateErrorQuery->count()); } - //echo "initialize"; - // put current page into global for navi $GLOBALS["passed"] = null; diff --git a/community_server/tests/Fixture/Migrations2Fixture.php b/community_server/tests/Fixture/Migrations2Fixture.php new file mode 100644 index 000000000..c8608cd18 --- /dev/null +++ b/community_server/tests/Fixture/Migrations2Fixture.php @@ -0,0 +1,45 @@ + ['type' => 'integer', 'length' => 10, 'unsigned' => true, 'null' => false, 'default' => null, 'comment' => '', 'autoIncrement' => true, 'precision' => null], + 'db_version' => ['type' => 'integer', 'length' => 11, 'unsigned' => false, 'null' => true, 'default' => '0', 'comment' => '', 'precision' => null, 'autoIncrement' => null], + '_constraints' => [ + 'primary' => ['type' => 'primary', 'columns' => ['id'], 'length' => []], + ], + '_options' => [ + 'engine' => 'InnoDB', + 'collation' => 'utf8mb4_unicode_ci' + ], + ]; + // @codingStandardsIgnoreEnd + /** + * Init method + * + * @return void + */ + public function init() + { + $this->table = "migrations"; + $this->records = [ + [ + 'id' => 1, + 'db_version' => 2, + ], + ]; + parent::init(); + } +} diff --git a/community_server/tests/TestCase/Controller/AppControllerTest.php b/community_server/tests/TestCase/Controller/AppControllerTest.php deleted file mode 100644 index 502ed46da..000000000 --- a/community_server/tests/TestCase/Controller/AppControllerTest.php +++ /dev/null @@ -1,46 +0,0 @@ -session(['StateUser.id' => 1]); - $this->get('/'); - $this->assertSession(1200, 'StateUser.balance'); - //$this->markTestIncomplete('Not implemented yet.'); - } - - -} diff --git a/community_server/tests/TestCase/Controller/Component/JsonRequestClientComponentTest.php b/community_server/tests/TestCase/Controller/Component/JsonRequestClientComponentTest.php index fb882478a..c1ba84ee3 100644 --- a/community_server/tests/TestCase/Controller/Component/JsonRequestClientComponentTest.php +++ b/community_server/tests/TestCase/Controller/Component/JsonRequestClientComponentTest.php @@ -51,19 +51,7 @@ class JsonRequestClientComponentTest extends TestCase $this->markTestIncomplete('Not implemented yet.'); } - /** - * Test getLoginServerUrl method - * - * @return void - */ - public function testGetLoginServerUrl() - { - //$this->markTestIncomplete('Not implemented yet.'); - $serverUrl = $this->JsonRequestClientComponent->getLoginServerUrl(); - $this->assertEquals($serverUrl, 'http://***REMOVED***'); - } - - /** + /** * Test is_base64 method * * @return void diff --git a/community_server/tests/TestCase/Controller/PagesControllerTest.php b/community_server/tests/TestCase/Controller/PagesControllerTest.php index 35fe1a13b..004d7c079 100644 --- a/community_server/tests/TestCase/Controller/PagesControllerTest.php +++ b/community_server/tests/TestCase/Controller/PagesControllerTest.php @@ -27,6 +27,10 @@ use Cake\View\Exception\MissingTemplateException; */ class PagesControllerTest extends IntegrationTestCase { + + public $fixtures = [ + 'app.Migrations2' + ]; /** * testMultipleGet method * @@ -35,9 +39,12 @@ class PagesControllerTest extends IntegrationTestCase public function testMultipleGet() { $this->get('/'); - $this->assertRedirect('account/'); + $locations = $this->_response->getHeader('Location'); + $this->assertRegExp('%.*/account/$%', $locations[0]); + $this->get('/'); - $this->assertRedirect('account/'); + $locations = $this->_response->getHeader('Location'); + $this->assertRegExp('%.*/account/$%', $locations[0]); } /** @@ -64,7 +71,7 @@ class PagesControllerTest extends IntegrationTestCase $this->get('/pages/not_existing'); $this->assertResponseError(); - $this->assertResponseContains('Error'); + $this->assertResponseContains('Not Found'); } /** @@ -78,8 +85,7 @@ class PagesControllerTest extends IntegrationTestCase $this->get('/pages/not_existing'); $this->assertResponseFailure(); - $this->assertResponseContains('Missing Template'); - $this->assertResponseContains('Stacktrace'); + $this->assertResponseContains('Template file \u0022Pages\/not_existing.ctp\u0022 is missing.'); $this->assertResponseContains('not_existing.ctp'); }