Minor - Improve unit tests consistency

1.10.x
Yannick Warnier 10 years ago
parent 669ae34589
commit 89f4575fbc
  1. 7
      .travis.yml
  2. 1
      main/inc/lib/add_courses_to_session_functions.lib.php
  3. 5
      main/inc/lib/add_many_session_to_category_functions.lib.php
  4. 6
      main/inc/lib/api.lib.php
  5. 1
      main/inc/lib/usermanager.lib.php
  6. 47
      tests/phpunit/classes/AccessurleditcoursestourlTest.lib.php
  7. 47
      tests/phpunit/classes/AccessurledituserstourlTest.lib.php
  8. 18
      tests/phpunit/classes/AddCourseToSessionTest.lib.php
  9. 280
      tests/phpunit/classes/AppPluginTest.class.php
  10. 1
      tests/phpunit/classes/UserManagerTest.lib.php

@ -5,9 +5,12 @@ php:
- 5.4
- 5.5
before_script: composer install -n
before_script:
- composer --self-update
- composer install -n
- composer update
before_install:
- sudo apt-get update -qq
- sudo apt-get install -qq php5-imagick php5-curl
- sudo apt-get install -qq php5-imagick php5-curl php5-intl php5-json
script: phpunit -c tests/phpunit

@ -11,7 +11,6 @@ class AddCourseToSession
* @param string $needle Search string
* @param string $type Type of search box ('single' or anything else)
* @return string XajaxResponse
* @assert () !== null
* @assert ('abc', 'single') !== null
* @assert ('abc', 'multiple') !== null
*/

@ -4,7 +4,10 @@
* Definition of the AddManySessionToCategoryFunctions class
* @package chamilo.library
*/
/**
* Requires
*/
require_once ('xajax/xajax.inc.php');
/**
* AddManySessionToCategoryFunctions class
*/

@ -1451,7 +1451,11 @@ function _api_format_user($user, $add_password = false)
*/
function api_get_user_info($user_id = '', $check_if_user_is_online = false, $show_password = false) {
if ($user_id == '') {
return _api_format_user($GLOBALS['_user']);
if (isset($GLOBALS['_user'])) {
return _api_format_user($GLOBALS['_user']);
}
// @todo trigger an exception here
return false;
}
$sql = "SELECT * FROM ".Database :: get_main_table(TABLE_MAIN_USER)."
WHERE user_id='".intval($user_id)."'";

@ -33,6 +33,7 @@ class UserManager
/**
* The default constructor only instanciates an empty user object
* @assert () === null
*/
public function __construct()
{

@ -1,47 +0,0 @@
<?php
/**
* Generated by PHPUnit_SkeletonGenerator on 2013-02-17 at 00:38:16.
*/
class AccessurleditcoursestourlTest extends PHPUnit_Framework_TestCase
{
/**
* @var Accessurleditcoursestourl
*/
protected $object;
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*/
protected function setUp()
{
ob_start();
require_once dirname(__FILE__).'/../../../main/inc/lib/access_url_edit_courses_to_url_functions.lib.php';
require_once dirname(__FILE__).'/../../../main/inc/lib/api.lib.php';
$this->object = new Accessurleditcoursestourl;
}
/**
* Tears down the fixture, for example, closes a network connection.
* This method is called after a test is executed.
*/
protected function tearDown()
{
ob_end_clean();
}
/**
* Generated from @assert () === false.
*
* @covers Accessurleditcoursestourl::search_courses
*/
public function testSearch_courses()
{
$this->assertThat(
false,
$this->logicalNot(
$this->equalTo($this->object->search_courses(null, null))
)
);
}
}

@ -1,47 +0,0 @@
<?php
/**
* Generated by PHPUnit_SkeletonGenerator on 2013-02-17 at 00:39:52.
*/
class AccessurledituserstourlTest extends PHPUnit_Framework_TestCase
{
/**
* @var Accessurledituserstourl
*/
protected $object;
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*/
protected function setUp()
{
ob_start();
require_once dirname(__FILE__).'/../../../main/inc/lib/access_url_edit_users_to_url_functions.lib.php';
require_once dirname(__FILE__).'/../../../main/inc/lib/api.lib.php';
$this->object = new Accessurledituserstourl;
}
/**
* Tears down the fixture, for example, closes a network connection.
* This method is called after a test is executed.
*/
protected function tearDown()
{
ob_end_clean();
}
/**
* Generated from @assert () === false.
*
* @covers Accessurledituserstourl::search_users
*/
public function testSearch_users()
{
$this->assertThat(
false,
$this->logicalNot(
$this->equalTo($this->object->search_users(null, null))
)
);
}
}

@ -1,4 +1,9 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Requires
*/
require_once ('xajax/xajax.inc.php');
/**
* Generated by PHPUnit_SkeletonGenerator on 2013-02-17 at 00:43:47.
*/
@ -28,19 +33,6 @@ class AddCourseToSessionTest extends PHPUnit_Framework_TestCase
{
}
/**
* Generated from @assert () !== null.
*
* @covers AddCourseToSession::search_courses
*/
public function testSearch_courses()
{
$this->assertNotSame(
null,
$this->object->search_courses()
);
}
/**
* Generated from @assert ('abc', 'single') !== null.
*

@ -1,280 +0,0 @@
<?php
/**
* Generated by PHPUnit_SkeletonGenerator on 2013-01-07 at 09:29:53.
*/
class AppPluginTest extends PHPUnit_Framework_TestCase
{
/**
* @var AppPlugin
*/
protected $object;
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*/
protected function setUp()
{
$this->object = new AppPlugin;
}
/**
* Tears down the fixture, for example, closes a network connection.
* This method is called after a test is executed.
*/
protected function tearDown()
{
}
/**
* @covers AppPlugin::read_plugins_from_path
* @todo Implement testRead_plugins_from_path().
*/
public function testRead_plugins_from_path()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
/**
* @covers AppPlugin::get_installed_plugins_by_region
* @todo Implement testGet_installed_plugins_by_region().
*/
public function testGet_installed_plugins_by_region()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
/**
* @covers AppPlugin::get_installed_plugins
* @todo Implement testGet_installed_plugins().
*/
public function testGet_installed_plugins()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
/**
* @covers AppPlugin::install
* @todo Implement testInstall().
*/
public function testInstall()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
/**
* @covers AppPlugin::uninstall
* @todo Implement testUninstall().
*/
public function testUninstall()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
/**
* @covers AppPlugin::get_areas_by_plugin
* @todo Implement testGet_areas_by_plugin().
*/
public function testGet_areas_by_plugin()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
/**
* @covers AppPlugin::is_valid_plugin_location
* @todo Implement testIs_valid_plugin_location().
*/
public function testIs_valid_plugin_location()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
/**
* @covers AppPlugin::is_valid_plugin
* @todo Implement testIs_valid_plugin().
*/
public function testIs_valid_plugin()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
/**
* @covers AppPlugin::get_plugin_regions
* @todo Implement testGet_plugin_regions().
*/
public function testGet_plugin_regions()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
/**
* @covers AppPlugin::load_region
* @todo Implement testLoad_region().
*/
public function testLoad_region()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
/**
* @covers AppPlugin::load_plugin_lang_variables
* @todo Implement testLoad_plugin_lang_variables().
*/
public function testLoad_plugin_lang_variables()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
/**
* @covers AppPlugin::get_all_plugin_contents_by_region
* @todo Implement testGet_all_plugin_contents_by_region().
*/
public function testGet_all_plugin_contents_by_region()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
/**
* @covers AppPlugin::get_plugin_info
* @todo Implement testGet_plugin_info().
*/
public function testGet_plugin_info()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
/**
* @covers AppPlugin::get_templates_list
* @todo Implement testGet_templates_list().
*/
public function testGet_templates_list()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
/**
* @covers AppPlugin::remove_all_regions
* @todo Implement testRemove_all_regions().
*/
public function testRemove_all_regions()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
/**
* @covers AppPlugin::add_to_region
* @todo Implement testAdd_to_region().
*/
public function testAdd_to_region()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
/**
* @covers AppPlugin::install_course_plugins
* @todo Implement testInstall_course_plugins().
*/
public function testInstall_course_plugins()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
/**
* @covers AppPlugin::add_course_settings_form
* @todo Implement testAdd_course_settings_form().
*/
public function testAdd_course_settings_form()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
/**
* @covers AppPlugin::set_course_settings_defaults
* @todo Implement testSet_course_settings_defaults().
*/
public function testSet_course_settings_defaults()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
/**
* @covers AppPlugin::save_course_settings
* @todo Implement testSave_course_settings().
*/
public function testSave_course_settings()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
/**
* @covers AppPlugin::get_plugin_course_settings
* @todo Implement testGet_plugin_course_settings().
*/
public function testGet_plugin_course_settings()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
}

@ -16,6 +16,7 @@ class UserManagerTest extends PHPUnit_Framework_TestCase
protected function setUp()
{
require_once dirname(__FILE__).'/../../../main/inc/global.inc.php';
require_once dirname(__FILE__).'/../../../main/inc/lib/database.constants.inc.php';
$this->object = new UserManager;
}

Loading…
Cancel
Save