Skip to content

Commit

Permalink
Dev: Add test for list_participants
Browse files Browse the repository at this point in the history
  • Loading branch information
olleharstedt committed Mar 18, 2020
1 parent b6d6f76 commit c57b200
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 0 deletions.
Binary file not shown.
84 changes: 84 additions & 0 deletions tests/unit/helpers/RemoteControlListParticipantsTest.php
@@ -0,0 +1,84 @@
<?php

namespace ls\tests;

/**
* Tests for the LimeSurvey remote API.
*/
class RemoteControlListParticipantsTest extends TestBaseClass
{
/**
* @var string
*/
protected static $username = null;

/**
* @var string
*/
protected static $password = null;

/**
* Setup.
*
* @return void
*/
public static function setupBeforeClass()
{
parent::setupBeforeClass();

self::$username = getenv('ADMINUSERNAME');
if (!self::$username) {
self::$username = 'admin';
}

self::$password = getenv('PASSWORD');
if (!self::$password) {
self::$password = 'password';
}

// Clear login attempts.
$dbo = \Yii::app()->getDb();
$query = sprintf('DELETE FROM {{failed_login_attempts}}');
$dbo->createCommand($query)->execute();
}

/**
*
* @return
*/
public function testConditions()
{
\Yii::import('application.helpers.remotecontrol.remotecontrol_handle', true);
\Yii::import('application.helpers.viewHelper', true);
\Yii::import('application.libraries.BigData', true);

/** @var CDbConnection */
$dbo = \Yii::app()->getDb();

/** @var string */
$filename = self::$surveysFolder . '/survey_archive_265351_listParticipants.lsa';
self::importSurvey($filename);

// Create handler.
$admin = new \AdminController('dummyid');
$handler = new \remotecontrol_handle($admin);

// Get session key.
$sessionKey = $handler->get_session_key(
self::$username,
self::$password
);
$this->assertNotEquals(['status' => 'Invalid user name or password'], $sessionKey);

/** @var array */
$list = $handler->list_participants(
$sessionKey,
self::$surveyId,
0,
999,
false,
['validuntil', 'validfrom']
);
var_dump($list);
}
}

0 comments on commit c57b200

Please sign in to comment.