changes asked on last pull requaest

This commit is contained in:
jygaulier
2012-05-22 18:50:45 +02:00
parent b6be659242
commit 1d58f89c36
15 changed files with 429 additions and 251 deletions

2
.gitignore vendored
View File

@@ -3,7 +3,5 @@
.DS_Store
!.gitignore
/vendor/
/datas
composer.lock
composer.phar
/libevent-0.0.5/.libs/

View File

@@ -11,10 +11,10 @@
/**
*
* @package APIv1
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com
*/
use Symfony\Component\HttpFoundation\Request;
use Silex\Application;

View File

@@ -61,14 +61,20 @@ class module_console_schedulerStart extends Command
return 1;
}
require_once __DIR__ . '/../../../../lib/bootstrap.php';
try {
$scheduler = new task_Scheduler();
$scheduler->run($input, $output);
} catch (\Exception $e) {
return $e->getCode();
switch($e->getCode())
{
case task_Scheduler::ERR_ALREADY_RUNNING: // 114 : aka EALREADY (Operation already in progress)
$exitCode = ERR_ALREADY_RUNNING;
break;
default:
$exitCode = 1; // default exit code (error)
break;
}
return $exitCode;
}
}
}

View File

@@ -72,8 +72,6 @@ class module_console_taskState extends Command
return self::EXITCODE_BAD_ARGUMENT;
}
require_once __DIR__ . '/../../../../lib/bootstrap.php';
$appbox = appbox::get_instance(\bootstrap::getCore());
$task_manager = new task_manager($appbox);

View File

@@ -12,7 +12,6 @@
/**
* @todo write tests
*
* @package KonsoleKomander
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com
*/
@@ -69,6 +68,7 @@ class module_console_taskrun extends Command
{
if ( ! setup::is_installed()) {
$output->writeln('Phraseanet is not set up');
return 1;
}
@@ -106,6 +106,7 @@ class module_console_taskrun extends Command
$this->task->run($runner, $input, $output);
} catch (Exception $e) {
$this->task->log(sprintf("taskrun : exception from 'run()', %s \n", $e->getMessage()));
return($e->getCode());
}

View File

@@ -22,6 +22,7 @@ class task_Scheduler
// how to schedule tasks (choose in 'run' method)
const METHOD_FORK = 'METHOD_FORK';
const METHOD_PROC_OPEN = 'METHOD_PROC_OPEN';
const ERR_ALREADY_RUNNING = 114; // aka EALREADY (Operation already in progress)
private $method;
@@ -52,7 +53,11 @@ class task_Scheduler
return appbox::get_instance(\bootstrap::getCore())->get_connection();
}
public function run($input = null, OutputInterface $output = null)
/*
* @throws Exception if scheduler is already running
* @todo doc all possible exception
*/
public function run(InputInterface $input = null, OutputInterface $output = null)
{
require_once dirname(__FILE__) . '/../../bootstrap.php';
$this->input = $input;
@@ -87,6 +92,7 @@ class task_Scheduler
fclose($schedlock);
throw new Exception('scheduler already running.', self::ERR_ALREADY_RUNNING);
return;
} else {
sleep(2);

View File

@@ -113,21 +113,35 @@ abstract class task_abstract
return $row['status'];
}
/*
* to be overwritten by tasks : echo text to be included in <head> in task interface
*/
public function printInterfaceHEAD()
{
return false;
}
/*
* to be overwritten by tasks : echo javascript to be included in <head> in task interface
*/
public function printInterfaceJS()
{
return false;
}
/**
*
* @return boolean
*/
public function printInterfaceHTML()
{
return false;
}
/**
*
* @return boolean
*/
public function getGraphicForm()
{
return false;
@@ -289,8 +303,7 @@ abstract class task_abstract
$this->log($e->getMessage());
$this->log(("Warning : abox connection lost, restarting in 10 min."));
for ($t = 60 * 10; $this->running && $t > 0; $t -- ) // DON'T do sleep(600) because it prevents ticks !
sleep(1);
$this->sleep(60 * 10);
$this->running = false;
@@ -429,6 +442,16 @@ abstract class task_abstract
}
}
protected function sleep($nsec)
{
$nsec = (int) $nsec;
if ($nsec < 0)
throw new \InvalidArgumentException(sprintf("(%s) is not > 0"));
while ($this->running && $nsec -- > 0) {
sleep(1);
}
}
private function getLockfilePath()
{
$registry = registry::get_instance();
@@ -515,6 +538,94 @@ abstract class task_abstract
abstract protected function run2();
protected function processLoop(&$box, &$rs)
{
$ret = self::STATE_OK;
$rowstodo = count($rs);
$rowsdone = 0;
if ($rowstodo > 0) {
$this->setProgress(0, $rowstodo);
}
foreach ($rs as $row) {
try {
// process one record
$this->processOneContent($box, $row);
} catch (Exception $e) {
$this->log("Exception : " . $e->getMessage() . " " . basename($e->getFile()) . " " . $e->getLine());
}
$this->records_done ++;
$this->setProgress($rowsdone, $rowstodo);
// post-process
$this->postProcessOneContent($box, $row);
$current_memory = memory_get_usage();
if ($current_memory >> 20 >= $this->maxmegs) {
$this->log(sprintf("Max memory (%s M) reached (actual is %s M)", $this->maxmegs, $current_memory));
$this->running = FALSE;
$ret = self::STATE_MAXMEGSREACHED;
}
if ($this->records_done >= (int) ($this->maxrecs)) {
$this->log(sprintf("Max records done (%s) reached (actual is %s)", $this->maxrecs, $this->records_done));
$this->running = FALSE;
$ret = self::STATE_MAXRECSDONE;
}
try {
$status = $this->getState();
if ($status == self::STATE_TOSTOP) {
$this->running = FALSE;
$ret = self::STATE_TOSTOP;
}
} catch (Exception $e) {
$this->running = FALSE;
}
if ( ! $this->running) {
break;
}
}
//
// if nothing was done, at least check the status
if (count($rs) == 0 && $this->running) {
$current_memory = memory_get_usage();
if ($current_memory >> 20 >= $this->maxmegs) {
$this->log(sprintf("Max memory (%s M) reached (current is %s M)", $this->maxmegs, $current_memory));
$this->running = FALSE;
$ret = self::STATE_MAXMEGSREACHED;
}
if ($this->records_done >= (int) ($this->maxrecs)) {
$this->log(sprintf("Max records done (%s) reached (actual is %s)", $this->maxrecs, $this->records_done));
$this->running = FALSE;
$ret = self::STATE_MAXRECSDONE;
}
try {
$status = $this->getState();
if ($status == self::STATE_TOSTOP) {
$this->running = FALSE;
$ret = self::STATE_TOSTOP;
}
} catch (Exception $e) {
$this->running = FALSE;
}
}
if ($rowstodo > 0) {
$this->setProgress(0, 0);
}
return $ret;
}
protected function loadSettings(SimpleXMLElement $sx_task_settings)
{
$this->period = (int) $sx_task_settings->period;

View File

@@ -120,6 +120,18 @@ abstract class task_appboxAbstract extends task_abstract
{
$ret = self::STATE_OK;
try {
// get the records to process
$rs = $this->retrieveContent($appbox);
$ret = $this->processLoop($appbox, $rs);
} catch (Exception $e) {
$this->log('Error : ' . $e->getMessage());
}
return $ret;
/*
$ret = self::STATE_OK;
try {
// get the records to process
$rs = $this->retrieveContent($appbox);
@@ -136,6 +148,7 @@ abstract class task_appboxAbstract extends task_abstract
}
foreach ($rs as $row) {
try {
// process one record
$this->processOneContent($appbox, $row);
@@ -149,7 +162,6 @@ abstract class task_appboxAbstract extends task_abstract
// post-process
$this->postProcessOneContent($appbox, $row);
// $this->check_memory_usage();
$current_memory = memory_get_usage();
if ($current_memory >> 20 >= $this->maxmegs) {
$this->log(sprintf("Max memory (%s M) reached (actual is %s M)", $this->maxmegs, $current_memory));
@@ -163,7 +175,6 @@ abstract class task_appboxAbstract extends task_abstract
$ret = self::STATE_MAXRECSDONE;
}
// $this->check_task_status();
try {
$status = $this->getState();
if ($status == self::STATE_TOSTOP) {
@@ -211,5 +222,6 @@ abstract class task_appboxAbstract extends task_abstract
}
return $ret;
*/
}
}

View File

@@ -86,6 +86,14 @@ abstract class task_databoxAbstract extends task_abstract
$this->sbas_id = (int) $row['sbas_id'];
$this->log('This task works now on ' . phrasea::sbas_names($this->sbas_id));
try {
// get the records to process
$databox = databox::get_instance((int)$row['sbas_id']);
} catch (Exception $e) {
$this->log(sprintf('Warning : can\' connect to sbas(%s)', $row['sbas_id']));
continue;
}
try {
$this->loadSettings(simplexml_load_string($row['settings']));
} catch (Exception $e) {
@@ -93,7 +101,15 @@ abstract class task_databoxAbstract extends task_abstract
continue;
}
$process_ret = $this->processSbas();
$process_ret = $this->processSbas($databox);
// close the cnx to the dbox
$connbas = $databox->get_connection();
if ($connbas instanceof PDO) {
$connbas->close();
unset($connbas);
}
switch ($process_ret) {
case self::STATE_MAXMEGSREACHED:
@@ -137,16 +153,24 @@ abstract class task_databoxAbstract extends task_abstract
*
* @return <type>
*/
protected function processSbas()
protected function processSbas(databox $databox)
{
$ret = self::STATE_OK;
$connbas = false;
try {
// get the records to process
$rs = $this->retrieveSbasContent($databox);
$ret = $this->processLoop($databox, $rs);
} catch (Exception $e) {
$this->log('Error : ' . $e->getMessage());
}
return $ret;
/*
$ret = self::STATE_OK;
try {
// get the records to process
$databox = databox::get_instance($this->sbas_id);
$connbas = $databox->get_connection();
$rs = $this->retrieveSbasContent($databox);
} catch (Exception $e) {
$this->log('Error : ' . $e->getMessage());
@@ -161,6 +185,7 @@ abstract class task_databoxAbstract extends task_abstract
}
foreach ($rs as $row) {
try {
// process one record
$this->processOneContent($databox, $row);
@@ -229,17 +254,12 @@ abstract class task_databoxAbstract extends task_abstract
}
}
// close the cnx to the dbox
if ($connbas instanceof PDO) {
$connbas->close();
unset($connbas);
}
if ($rowstodo > 0) {
$this->setProgress(0, 0);
}
return $ret;
*/
}
}

View File

@@ -382,6 +382,7 @@ class task_period_archive extends task_abstract
// runner = manual : can't restart so simply quit
}
$this->running = FALSE;
return;
}
@@ -399,19 +400,16 @@ class task_period_archive extends task_abstract
$this->setState(self::STATE_STOPPED);
}
$this->running = FALSE;
return;
}
$this->setLastExecTime();
$row = NULL;
try {
$sql = "SELECT * FROM task2 WHERE task_id = :task_id";
$stmt = $conn->prepare($sql);
$stmt->execute(array(':task_id' => $this->getID()));
$row = $stmt->fetch(PDO::FETCH_ASSOC);
$stmt->closeCursor();
if ($row && $this->sxTaskSettings = @simplexml_load_string($row['settings'])) {
if (!($this->sxTaskSettings = @simplexml_load_string($this->getSettings()))) {
throw new Exception(sprintf('Error fetching or reading settings of the task \'%d\'', $this->getID()));
} else {
// copy settings to task, so it's easier to get later
$this->move_archived = p4field::isyes($this->sxTaskSettings->move_archived);
$this->move_error = p4field::isyes($this->sxTaskSettings->move_error);
@@ -424,15 +422,13 @@ class task_period_archive extends task_abstract
if ($cold <= 0 || $cold >= 60 * 60) {
$cold = 60;
}
} else {
throw new Exception(sprintf('Error fetching or reading settings of the task \'%d\'', $this->getID()));
}
} catch (Exception $e) {
if ($this->getRunner() == self::RUNNER_SCHEDULER) {
$this->log(sprintf(('Warning : error fetching or reading settings of the task \'%d\', restarting in 10 min.'), $this->getID()));
for ($t = 60 * 10; $this->running && $t; $t -- ) // DON'T do sleep(600) because it prevents ticks !
sleep(1);
$this->sleep(60 * 10);
$this->setState(self::STATE_TORESTART);
} else {
$this->log(sprintf(('Error : error fetching task \'%d\', stopping.'), $this->getID()));
@@ -440,11 +436,15 @@ class task_period_archive extends task_abstract
$this->setState(self::STATE_STOPPED);
}
$this->running = FALSE;
return;
}
if ($row['status'] == self::STATE_TOSTOP) {
$status = $this->getState();
if ($status == self::STATE_TOSTOP) {
$this->running = FALSE;
return;
}
@@ -485,13 +485,13 @@ class task_period_archive extends task_abstract
case 'MAXRECSDONE':
case 'MAXMEMORY':
case 'MAXLOOP':
if ($row['status'] == self::STATE_STARTED && $this->getRunner() !== self::RUNNER_MANUAL) {
if ($status == self::STATE_STARTED && $this->getRunner() !== self::RUNNER_MANUAL) {
$this->setState(self::STATE_TORESTART);
$this->running = FALSE;
}
break;
default:
if ($row['status'] == self::STATE_STARTED) {
if ($status == self::STATE_STARTED) {
$this->setState(self::STATE_STOPPED);
$this->running = FALSE;
}

View File

@@ -391,38 +391,50 @@ class task_period_cindexer extends task_abstract
}
$args = array();
$args_nopwd = array();
if ($this->host) {
$args[] = '-h=' . $this->host;
$args_nopwd[] = '-h=' . $this->host;
}
if ($this->port) {
$args[] = '-P=' . $this->port;
$args_nopwd[] = '-P=' . $this->port;
}
if ($this->base) {
$args[] = '-b=' . $this->base;
$args_nopwd[] = '-b=' . $this->base;
}
if ($this->user) {
$args[] = '-u=' . $this->user;
$args_nopwd[] = '-u=' . $this->user;
}
if ($this->password) {
$args[] = '-p=' . $this->password;
$args_nopwd[] = '-p=******';
}
if ($this->socket) {
$args[] = '--socket=' . $this->socket;
$args_nopwd[] = '--socket=' . $this->socket;
}
if ($this->use_sbas) {
$args[] = '-o';
$args_nopwd[] = '-o';
}
if ($this->charset) {
$args[] = '--default-character-set=' . $this->charset;
$args_nopwd[] = '--default-character-set=' . $this->charset;
}
if ($this->debugmask > 0) {
$args[] = '-d=' . $this->debugmask;
$args_nopwd[] = '-d=' . $this->debugmask;
}
if ($this->nolog) {
$args[] = '-n';
$args_nopwd[] = '-n';
}
if ($this->winsvc_run) {
$args[] = '--run';
$args_nopwd[] = '--run';
}
$registry = registry::get_instance();
@@ -434,13 +446,13 @@ class task_period_cindexer extends task_abstract
$this->log(sprintf("running cindexer with method %s", $this->method));
switch ($this->method) {
case self::METHOD_PROC_OPEN:
$this->run_with_proc_open($cmd, $args);
$this->run_with_proc_open($cmd, $args, $args_nopwd);
break;
case self::METHOD_FORK:
$this->run_with_fork($cmd, $args);
$this->run_with_fork($cmd, $args, $args_nopwd);
break;
case self::METHOD_EXEC:
$this->run_with_exec($cmd, $args);
$this->run_with_exec($cmd, $args, $args_nopwd);
break;
}
@@ -453,7 +465,7 @@ class task_period_cindexer extends task_abstract
}
}
private function run_with_proc_open($cmd, $args)
private function run_with_proc_open($cmd, $args, $args_nopwd)
{
$nullfile = $this->system == 'WINDOWS' ? 'NUL' : '/dev/null';
@@ -463,7 +475,8 @@ class task_period_cindexer extends task_abstract
$pipes = array();
$this->log(sprintf('cmd=\'%s %s\'', $cmd, implode(' ', $args)));
$this->log(sprintf('cmd=\'%s %s\'', $cmd, implode(' ', $args_nopwd)));
$process = proc_open($cmd . ' ' . implode(' ', $args), $descriptors, $pipes, $this->binpath, null, array('bypass_shell' => true));
$pid = NULL;
@@ -544,7 +557,7 @@ class task_period_cindexer extends task_abstract
proc_close($process);
}
private function run_with_fork($cmd, $args)
private function run_with_fork($cmd, $args, $args_nopwd)
{
$pid = pcntl_fork();
if ($pid == -1) {
@@ -610,7 +623,7 @@ class task_period_cindexer extends task_abstract
}
}
private function run_with_exec($cmd, $args)
private function run_with_exec($cmd, $args, $args_nopwd)
{
pcntl_exec($cmd, $args);
sleep(2);

View File

@@ -54,8 +54,9 @@ class task_period_ftpPull extends task_appboxAbstract
$pvalue = $parm2[$pname];
if ($ns = $dom->getElementsByTagName($pname)->item(0)) {
// le champ existait dans le xml, on supprime son ancienne valeur (tout le contenu)
while (($n = $ns->firstChild))
while (($n = $ns->firstChild)) {
$ns->removeChild($n);
}
} else {
// le champ n'existait pas dans le xml, on le cree
$dom->documentElement->appendChild($dom->createTextNode("\t"));
@@ -200,8 +201,9 @@ class task_period_ftpPull extends task_appboxAbstract
if ($parm[$f] !== NULL) {
if (($ns = $domTaskSettings->getElementsByTagName($f)->item(0)) != NULL) {
// le champ existait dans le xml, on supprime son ancienne valeur (tout le contenu)
while (($n = $ns->firstChild))
while (($n = $ns->firstChild)) {
$ns->removeChild($n);
}
} else {
// le champ n'existait pas dans le xml, on le cree
$domTaskSettings->documentElement->appendChild($domTaskSettings->createTextNode("\t"));
@@ -213,13 +215,15 @@ class task_period_ftpPull extends task_appboxAbstract
$xmlchanged = true;
}
}
if ($xmlchanged)
if ($xmlchanged) {
$parm["xml"] = $domTaskSettings->saveXML();
}
}
}
// si on doit changer le xml, on verifie qu'il est valide
if ($parm["xml"] && ! DOMDocument::loadXML($parm["xml"])) {
return(false);
}
@@ -247,9 +251,11 @@ class task_period_ftpPull extends task_appboxAbstract
return true;
} catch (Exception $e) {
return false;
}
} else {
return true;
}
}
@@ -286,8 +292,10 @@ class task_period_ftpPull extends task_appboxAbstract
$this->log('\'' . $this->localpath . '\' is not writeable');
$this->running = FALSE;
}
if ( ! $this->running) {
$this->set_status(self::STATE_STOPPED);
return array();
}
@@ -297,6 +305,7 @@ class task_period_ftpPull extends task_appboxAbstract
$ftp->chdir($this->ftppath);
$list_1 = $ftp->list_directory(true);
$done = 0;
$todo = count($list_1);
$this->setProgress($done, $todo);
@@ -304,19 +313,14 @@ class task_period_ftpPull extends task_appboxAbstract
echo "attente de 25sec pour avoir les fichiers froids...\n";
}
for ($t = 25; $this->running && $t > 0; $t -- ) { // DON'T do sleep($this->period - $when_started) because it prevents ticks !
$s = $this->getState();
if ($s == self::STATE_TOSTOP) {
if (isset($ftp) && $ftp instanceof ftpclient)
$this->sleep(25);
if ( ! $this->running) {
if (isset($ftp) && $ftp instanceof ftpclient) {
$ftp->close();
$this->set_status(self::STATE_STOPPED);
$this->running = FALSE;
}
return array();
}
else {
sleep(1);
}
}
$list_2 = $ftp->list_directory(true);
@@ -325,13 +329,15 @@ class task_period_ftpPull extends task_appboxAbstract
$this->setProgress($done, $todo);
if ( ! isset($list_2[$filepath])) {
if ($this->debug)
if ($this->debug) {
echo "le fichier $filepath a disparu...\n";
}
continue;
}
if ($list_2[$filepath] !== $timestamp) {
if ($this->debug)
if ($this->debug) {
echo "le fichier $filepath a ete modifie depuis le dernier passage...\n";
}
continue;
}
@@ -339,26 +345,30 @@ class task_period_ftpPull extends task_appboxAbstract
echo "Ok pour rappatriement de $filepath vers $finalpath\n";
try {
if (file_exists($finalpath))
if (file_exists($finalpath)) {
throw new Exception("Un fichier du meme nom ($finalpath) existe deja...");
}
system_file::mkdir(dirname($finalpath));
$ftp->get($finalpath, $filepath);
$ftp->delete($filepath);
} catch (Exception $e) {
if ($this->debug)
if ($this->debug) {
echo "Erreur lors du rappatriement de $filepath : " . $e->getMessage() . "\n";
}
}
}
$ftp->close();
$this->setProgress(0, 0);
} catch (Exception $e) {
if (isset($ftp) && $ftp instanceof ftpclient)
if (isset($ftp) && $ftp instanceof ftpclient) {
$ftp->close();
}
echo $e->getMessage() . "\n";
return array();
}
}

View File

@@ -29,7 +29,7 @@ class task_period_test extends task_appboxAbstract
protected function retrieveContent(appbox $appbox)
{
$this->log('test class, retrive content');
$this->log('test class, retrieve content');
return array(array('hello'), array('world'));
}

View File

@@ -3,11 +3,14 @@
require_once __DIR__ . '/../../PhraseanetWebTestCaseAuthenticatedAbstract.class.inc';
use Symfony\Component\Console\Tester\CommandTester;
use \Symfony\Component\Console\Application;
use Symfony\Component\Console\Application;
class module_console_schedulerStateTest extends PHPUnit_Framework_TestCase
{
/**
* @covers module_console_schedulerState::execute
*/
public function testExecute()
{
// mock the Kernel or create one depending on your needs

View File

@@ -32,10 +32,10 @@ class task_abstractTest extends PhraseanetPHPUnitAbstract
public function testActive()
{
self::$task->setActive(true);
self::assertTrue(self::$task->isActive());
$this->assertTrue(self::$task->isActive());
self::$task->setActive(false);
self::assertFalse(self::$task->isActive());
$this->assertFalse(self::$task->isActive());
}
/**
@@ -45,10 +45,10 @@ class task_abstractTest extends PhraseanetPHPUnitAbstract
public function testState()
{
self::$task->setState(\task_abstract::STATE_STOPPED);
self::assertEquals(\task_abstract::STATE_STOPPED, self::$task->getState());
$this->assertEquals(\task_abstract::STATE_STOPPED, self::$task->getState());
self::$task->setState(\task_abstract::STATE_TOSTOP);
self::assertEquals(\task_abstract::STATE_TOSTOP, self::$task->getState());
$this->assertEquals(\task_abstract::STATE_TOSTOP, self::$task->getState());
}
/**
@@ -58,7 +58,7 @@ class task_abstractTest extends PhraseanetPHPUnitAbstract
public function testTitle()
{
self::$task->setTitle('a_test_title');
self::assertEquals('a_test_title', self::$task->getTitle());
$this->assertEquals('a_test_title', self::$task->getTitle());
}
/**
@@ -70,13 +70,13 @@ class task_abstractTest extends PhraseanetPHPUnitAbstract
{
self::$task->resetCrashCounter();
self::$task->incrementCrashCounter();
self::assertEquals(1, self::$task->getCrashCounter());
$this->assertEquals(1, self::$task->getCrashCounter());
self::$task->incrementCrashCounter();
self::assertEquals(2, self::$task->getCrashCounter());
$this->assertEquals(2, self::$task->getCrashCounter());
self::$task->resetCrashCounter();
self::assertEquals(0, self::$task->getCrashCounter());
$this->assertEquals(0, self::$task->getCrashCounter());
}
/**
@@ -92,8 +92,8 @@ class task_abstractTest extends PhraseanetPHPUnitAbstract
$settings = self::$task->getSettings();
$sxSettings = @simplexml_load_string($settings);
self::assertTrue($sxSettings !== FALSE);
self::assertEquals($sxGoodSettings->saveXML(), $sxSettings->saveXML());
$this->assertTrue($sxSettings !== FALSE);
$this->assertEquals($sxGoodSettings->saveXML(), $sxSettings->saveXML());
}
/**
@@ -112,10 +112,10 @@ class task_abstractTest extends PhraseanetPHPUnitAbstract
public function testRunner()
{
self::$task->setRunner(\task_abstract::RUNNER_MANUAL);
self::assertTrue(\task_abstract::RUNNER_MANUAL === self::$task->getRunner());
$this->assertTrue(\task_abstract::RUNNER_MANUAL === self::$task->getRunner());
self::$task->setRunner(\task_abstract::RUNNER_SCHEDULER);
self::assertTrue(\task_abstract::RUNNER_SCHEDULER === self::$task->getRunner());
$this->assertTrue(\task_abstract::RUNNER_SCHEDULER === self::$task->getRunner());
}
/**
@@ -143,14 +143,14 @@ class task_abstractTest extends PhraseanetPHPUnitAbstract
try {
$fd = $methodL->invoke(self::$task);
} catch (Exception $e) {
self::fail('file should not be locked');
$this->fail('file should not be locked');
}
self::assertInternalType('resource', $fd);
$this->assertInternalType('resource', $fd);
// now task should be locked
try {
$fd = $methodL->invoke(self::$task);
self::fail('file should be locked');
$this->fail('file should be locked');
} catch (Exception $e) {
}
@@ -162,9 +162,9 @@ class task_abstractTest extends PhraseanetPHPUnitAbstract
try {
$fd = $methodL->invoke(self::$task);
} catch (Exception $e) {
self::fail('file should not be locked');
$this->fail('file should not be locked');
}
self::assertInternalType('resource', $fd);
$this->assertInternalType('resource', $fd);
// leave the file unlocked
$methodU->invokeArgs(self::$task, array($fd));