From baaa60785d8676b0eec6a99af7c50d13120dddfc Mon Sep 17 00:00:00 2001 From: Lapiu Dev Date: Tue, 13 Jun 2023 08:15:28 -0600 Subject: [PATCH 1/4] Fixed issue #18823: STATA Export fails with certain question types Tests added. --- .../ExportResponsesStataXmlTest.php | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 tests/unit/helpers/remotecontrol/ExportResponsesStataXmlTest.php diff --git a/tests/unit/helpers/remotecontrol/ExportResponsesStataXmlTest.php b/tests/unit/helpers/remotecontrol/ExportResponsesStataXmlTest.php new file mode 100644 index 00000000000..eebb61bf902 --- /dev/null +++ b/tests/unit/helpers/remotecontrol/ExportResponsesStataXmlTest.php @@ -0,0 +1,44 @@ +getPluginManager()->loadPlugin(self::$pluginName); + + // Activate it, if not already + self::installAndActivatePlugin(self::$pluginName); + + // Import survey + $filename = self::$surveysFolder . '/survey_archive_RemoteControlExportResponses.lsa'; + self::importSurvey($filename); + } + + /** + * Get responses in stataxml format. + */ + public function testGetResponses() + { + $sessionKey = $this->handler->get_session_key($this->getUsername(), $this->getPassword()); + + $result = $this->handler->export_responses($sessionKey, self::$surveyId, 'stataxml'); + $this->assertNotNull($result); + } +} From d8be5111b36b0c26dcf87c6c9394e7699dab73fd Mon Sep 17 00:00:00 2001 From: Lapiu Dev Date: Tue, 13 Jun 2023 10:22:31 -0600 Subject: [PATCH 2/4] Fixed issue #18823: STATA Export fails with certain question types Survey deleted to avoid error on another test. --- .../helpers/remotecontrol/ExportResponsesStataXmlTest.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/unit/helpers/remotecontrol/ExportResponsesStataXmlTest.php b/tests/unit/helpers/remotecontrol/ExportResponsesStataXmlTest.php index eebb61bf902..7e03505e19a 100644 --- a/tests/unit/helpers/remotecontrol/ExportResponsesStataXmlTest.php +++ b/tests/unit/helpers/remotecontrol/ExportResponsesStataXmlTest.php @@ -20,7 +20,7 @@ public static function setUpBeforeClass(): void \Yii::import('application.helpers.viewHelper', true); \Yii::import('application.libraries.BigData', true); - // Get a handle to the plugin being testes + // Get a handle to the plugin being tested self::$plugin = App()->getPluginManager()->loadPlugin(self::$pluginName); // Activate it, if not already @@ -41,4 +41,9 @@ public function testGetResponses() $result = $this->handler->export_responses($sessionKey, self::$surveyId, 'stataxml'); $this->assertNotNull($result); } + + public static function tearDownAfterClass(): void + { + \Survey::model()->deleteSurvey(self::$surveyId); + } } From fcf844881322c2f79b112bd94ba34aac5a7cc693 Mon Sep 17 00:00:00 2001 From: Lapiu Dev Date: Tue, 13 Jun 2023 11:43:24 -0600 Subject: [PATCH 3/4] Fixed issue #18823: STATA Export fails with certain question types Loading a different survey. --- .../helpers/remotecontrol/ExportResponsesStataXmlTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/unit/helpers/remotecontrol/ExportResponsesStataXmlTest.php b/tests/unit/helpers/remotecontrol/ExportResponsesStataXmlTest.php index 7e03505e19a..9fab1cacf0f 100644 --- a/tests/unit/helpers/remotecontrol/ExportResponsesStataXmlTest.php +++ b/tests/unit/helpers/remotecontrol/ExportResponsesStataXmlTest.php @@ -27,7 +27,7 @@ public static function setUpBeforeClass(): void self::installAndActivatePlugin(self::$pluginName); // Import survey - $filename = self::$surveysFolder . '/survey_archive_RemoteControlExportResponses.lsa'; + $filename = self::$surveysFolder . '/survey_export_responses_with_tokens.lsa'; self::importSurvey($filename); } @@ -44,6 +44,6 @@ public function testGetResponses() public static function tearDownAfterClass(): void { - \Survey::model()->deleteSurvey(self::$surveyId); + self::$testSurvey->delete(); } } From 096c84fc3c804ad6daf210f8d67fc5fa69694f32 Mon Sep 17 00:00:00 2001 From: Gabriel Jenik Date: Wed, 14 Jun 2023 11:16:48 -0300 Subject: [PATCH 4/4] DEV: Code Review --- .../remotecontrol/ExportResponsesStataXmlTest.php | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/tests/unit/helpers/remotecontrol/ExportResponsesStataXmlTest.php b/tests/unit/helpers/remotecontrol/ExportResponsesStataXmlTest.php index 9fab1cacf0f..4bd13dfa36d 100644 --- a/tests/unit/helpers/remotecontrol/ExportResponsesStataXmlTest.php +++ b/tests/unit/helpers/remotecontrol/ExportResponsesStataXmlTest.php @@ -7,10 +7,7 @@ */ class ExportResponsesStataXmlTest extends BaseTest { - private static $username = null; - private static $password = null; private static $pluginName = 'ExportSTATAxml'; - private static $plugin; public static function setUpBeforeClass(): void { @@ -20,9 +17,6 @@ public static function setUpBeforeClass(): void \Yii::import('application.helpers.viewHelper', true); \Yii::import('application.libraries.BigData', true); - // Get a handle to the plugin being tested - self::$plugin = App()->getPluginManager()->loadPlugin(self::$pluginName); - // Activate it, if not already self::installAndActivatePlugin(self::$pluginName); @@ -41,9 +35,4 @@ public function testGetResponses() $result = $this->handler->export_responses($sessionKey, self::$surveyId, 'stataxml'); $this->assertNotNull($result); } - - public static function tearDownAfterClass(): void - { - self::$testSurvey->delete(); - } }