HEX
Server: Apache
System: Linux WWW 6.1.0-40-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.153-1 (2025-09-20) x86_64
User: web11 (1011)
PHP: 8.2.29
Disabled: NONE
Upload Files
File: /var/www/apklausos/tests/unit/plugins/LimesurveyApi/GetQuestionsTest.php
<?php

namespace ls\tests;

/**
 * Tests for the GetQuestions function in LimeSurveyApi.
 */
class GetQuestionsTest extends TestBaseClass
{
    public static function setupBeforeClass(): void
    {
        parent::setupBeforeClass();

        self::importSurvey(self::$surveysFolder . '/survey_GetQuestionTest.lss');
    }

    /**
     * Testing that there are three questions in English.
     */
    public function testGetQuestionsInEnglish()
    {
        $limeSurveyApi = new \LimeSurvey\PluginManager\LimesurveyApi();
        // The function takes English by default.
        $questionsInEnglish = $limeSurveyApi->getQuestions(self::$surveyId);

        $this->assertCount(3, $questionsInEnglish, 'Unexpected number of questions in English returned.');
    }

    /**
     * Testing that there are three questions in Spanish.
     */
    public function testGetQuestionsInSpanish()
    {
        $limeSurveyApi = new \LimeSurvey\PluginManager\LimesurveyApi();

        $questionsInSpanish = $limeSurveyApi->getQuestions(self::$surveyId, 'es');

        $this->assertCount(3, $questionsInSpanish, 'Unexpected number of questions in Spanish returned.');
    }

    /**
     * Testing that there aren't any questions in French.
     */
    public function testGetQuestionsInFrench()
    {
        $limeSurveyApi = new \LimeSurvey\PluginManager\LimesurveyApi();

        $questionsInFrench = $limeSurveyApi->getQuestions(self::$surveyId, 'fr');

        $this->assertEmpty($questionsInFrench, 'Unexpected number of questions in French returned.');
    }
}