Skip to content

Commit

Permalink
PHPunit
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Mar 11, 2018
1 parent f1f539d commit b5ca4ca
Showing 1 changed file with 41 additions and 41 deletions.
82 changes: 41 additions & 41 deletions test/phpunit/TicketsupTest.php
Expand Up @@ -25,19 +25,19 @@
namespace test\unit;

global $conf,$user,$langs,$db;
//define('TEST_DB_FORCE_TYPE','mysql'); // This is to force using mysql driver
//define('TEST_DB_FORCE_TYPE','mysql'); // This is to force using mysql driver
//require_once 'PHPUnit/Autoload.php';
$res = false;
if (file_exists(dirname(__FILE__).'/../../../../htdocs/master.inc.php')) {
$res = require_once dirname(__FILE__).'/../../../../htdocs/master.inc.php';
} elseif (file_exists(dirname(__FILE__).'/../../../../../htdocs/master.inc.php')) {
$res = require_once dirname(__FILE__).'/../../../../../htdocs/master.inc.php';
} else {
die('Include of mains fails');
}
require_once dirname(__FILE__).'/../../htdocs/master.inc.php';
require_once dirname(__FILE__).'/../../htdocs/user/class/usergroup.class.php';
require_once dirname(__FILE__).'/../../htdocs/ticketsup/class/ticketsup.class.php';

if (empty($user->id)) {
print "Load permissions for admin user nb 1\n";
$user->fetch(1);
$user->getrights();
}
$conf->global->MAIN_DISABLE_ALL_MAILS=1;

require_once dirname(__FILE__).'/../../class/ticketsup.class.php';


if (empty($user->id)) {
Expand Down Expand Up @@ -144,18 +144,18 @@ public function testTicketsupCreate()
$localobject->initAsSpecimen();
$localobject->fk_statut = '\'1=1';
$result=$localobject->create($user);

print __METHOD__." result=".$result."\n";
$this->assertEquals($result, -1);

// Try to create one with correct values
$localobject=new \Ticketsup($this->savdb);
$localobject->initAsSpecimen();
$result=$localobject->create($user);

print __METHOD__." result=".$result."\n";
$this->assertLessThan($result, 0);


return $result;
}
Expand Down Expand Up @@ -209,7 +209,7 @@ public function testTicketsupmarkAsRead($localobject)
$this->assertLessThan($result, 0);
return $localobject;
}

/**
* testTicketsupsetProject
*
Expand All @@ -226,16 +226,16 @@ public function testTicketsupsetProject($localobject)
$user=$this->savuser;
$langs=$this->savlangs;
$db=$this->savdb;

$project_id = 1;

$result=$localobject->setProject($project_id);
print __METHOD__." id=".$localobject->id." result=".$result."\n";

$this->assertLessThan($result, 0);
return $localobject;
}

/**
* testTicketsupsetContract
*
Expand All @@ -252,16 +252,16 @@ public function testTicketsupsetContract($localobject)
$user=$this->savuser;
$langs=$this->savlangs;
$db=$this->savdb;

$contract_id = 1;

$result=$localobject->setContract($contract_id);
print __METHOD__." id=".$localobject->id." result=".$result."\n";

$this->assertLessThan($result, 0);
return $localobject;
}

/**
* testTicketsupsetProgression
*
Expand All @@ -278,16 +278,16 @@ public function testTicketsupsetProgression($localobject)
$user=$this->savuser;
$langs=$this->savlangs;
$db=$this->savdb;

$percent = 80;

$result=$localobject->setProgression($percent);
print __METHOD__." id=".$localobject->id." result=".$result."\n";

$this->assertLessThan($result, 0);
return $localobject;
}

/**
* testTicketsupassignUser
*
Expand All @@ -304,17 +304,17 @@ public function testTicketsupassignUser($localobject)
$user=$this->savuser;
$langs=$this->savlangs;
$db=$this->savdb;

$user_id_to_assign = 1;

$result=$localobject->assignUser($user, $user_id_to_assign);
;
print __METHOD__." id=".$localobject->id." result=".$result."\n";

$this->assertLessThan($result, 0);
return $localobject;
}

/**
* testTicketsupassignUserOther
*
Expand All @@ -331,17 +331,17 @@ public function testTicketsupassignUserOther($localobject)
$user=$this->savuser;
$langs=$this->savlangs;
$db=$this->savdb;

$user_id_to_assign = 2;

$result=$localobject->assignUser($user, $user_id_to_assign);
;
print __METHOD__." id=".$localobject->id." result=".$result."\n";

$this->assertLessThan($result, 0);
return $localobject;
}

/**
* testTicketsupcreateTicketLog
*
Expand All @@ -358,13 +358,13 @@ public function testTicketsupcreateTicketLog($localobject)
$user=$this->savuser;
$langs=$this->savlangs;
$db=$this->savdb;


$message = 'Test ticket log';
$noemail = 1;
$result=$localobject->createTicketLog($user, $message, $noemail);
print __METHOD__." id=".$localobject->id." result=".$result."\n";

$this->assertLessThan($result, 0);
return $localobject;
}
Expand All @@ -385,15 +385,15 @@ public function testTicketsupclose($localobject)
$user=$this->savuser;
$langs=$this->savlangs;
$db=$this->savdb;

$result=$localobject->close();
print __METHOD__." id=".$localobject->id." result=".$result."\n";

$this->assertLessThan($result, 0);
return $localobject->id;
}


/**
* testTicketsupDelete
*
Expand All @@ -405,7 +405,7 @@ public function testTicketsupclose($localobject)
*/
public function testTicketsupDelete($id)
{

global $conf,$user,$langs,$db;
$conf=$this->savconf;
$user=$this->savuser;
Expand Down

0 comments on commit b5ca4ca

Please sign in to comment.