Fixed failing tests + improved return value of api_mail_html()

skala
Yannick Warnier 15 years ago
parent adf179747a
commit 4c009de082
  1. 5
      main/inc/lib/system_announcements.lib.php
  2. 7
      tests/main/inc/lib/main_api.lib.test.php
  3. 14
      tests/main/inc/lib/system_announcements.lib.test.php
  4. 7
      tests/main/inc/lib/text.lib.test.php
  5. 6
      tests/main/inc/lib/usermanager.lib.test.php

@ -469,7 +469,8 @@ class SystemAnnouncementManager
return false;
}
while($row = Database::fetch_array($result,'ASSOC')) {
$res = @api_mail_html(api_get_person_name($row['firstname'], $row['lastname'], null, PERSON_NAME_EMAIL_ADDRESS), $row['email'], api_html_entity_decode(stripslashes($title), ENT_QUOTES, $charset), api_html_entity_decode(stripslashes(str_replace(array('\r\n', '\n', '\r'),'',$content)), ENT_QUOTES, $charset), api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'), null, PERSON_NAME_EMAIL_ADDRESS), api_get_setting('emailAdministrator'));
$res = @api_mail_html(api_get_person_name($row['firstname'], $row['lastname'], null, PERSON_NAME_EMAIL_ADDRESS), $row['email'], api_html_entity_decode(stripslashes($title), ENT_QUOTES, $charset), api_html_entity_decode(stripslashes(str_replace(array('\r\n', '\n', '\r'),'',$content)), ENT_QUOTES, $charset), api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'), null, PERSON_NAME_EMAIL_ADDRESS), api_get_setting('emailAdministrator')) || $res;
}
return $res; //true if at least one e-mail was sent
}
}
}

@ -557,13 +557,6 @@ class TestMainApi extends UnitTestCase {
$this->assertTrue(is_bool($res));
}
function testApiParseTex(){
global $textext;
$res = api_parse_tex($textext);
$this->assertTrue(is_string($res));
//var_dump($res);
}
function testApiTimeToHms(){
$seconds = -1;
ob_start();

@ -65,11 +65,21 @@ class TestSystemAnnouncementManager extends UnitTestCase {
//var_dump($res);
}
function test_send_system_announcement_by_email_is_null() {
function test_send_system_announcement_by_email_is_true_on_teacher_null() {
global $_user, $_setting, $charset;
$title = $content = $teacher = $student = '';
$res=SystemAnnouncementManager::send_system_announcement_by_email($title,$content,$teacher, $student);
$this->assertTrue(is_null($res));
$this->assertTrue($res);
}
function test_send_system_announcement_by_email_is_true_on_teacher_not_null() {
global $_user, $_setting, $charset;
$title = 'abc';
$content = 'bcd';
$student = 0;
$teacher = 1;
$res=SystemAnnouncementManager::send_system_announcement_by_email($title,$content,$teacher, $student);
$this->assertTrue($res);
}
function test_set_visibility() {

@ -139,5 +139,12 @@ class TestText extends UnitTestCase {
$this->assertTrue(is_string($res));
//var_dump($res);
}
function testApiParseTex(){
$textext = 'abc';
$res = api_parse_tex($textext); //this function is practically deprecated now, it doesn't do anything
$this->assertEqual($textext,$res);
}
}
?>

@ -279,11 +279,11 @@ class TestUserManager extends UnitTestCase {
$this->assertFalse(is_string($res));
}
function testRemoveUserProduction() {
function testRemoveUserProductionIsFalseWhenProductionDoesNotExist() {
$user_id=1;
$production='my_files';
$production='my_files/abc'; //shouldn't exist
$res=UserManager::remove_user_production($user_id,$production);
$this->assertTrue(is_null($res));
$this->assertFalse($res);
}
function testResizePicture() {

Loading…
Cancel
Save