2014-02-05 10:10:05 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test for course workflow.
|
|
|
|
* @category Tests
|
|
|
|
* @author Oreolek
|
|
|
|
* @license AGPL
|
|
|
|
**/
|
|
|
|
class CoursesTest extends Unittest_Database_TestCase
|
|
|
|
{
|
|
|
|
protected $_database_connection = 'test';
|
|
|
|
|
|
|
|
protected function getdataset()
|
|
|
|
{
|
|
|
|
return $this->createXMLDataSet(Kohana::find_file('tests', 'test_data/courses', 'xml'));
|
|
|
|
}
|
|
|
|
|
2016-10-11 08:37:54 +03:00
|
|
|
public function get_setup_operation()
|
|
|
|
{
|
2014-02-05 10:10:05 +02:00
|
|
|
// whether you want cascading truncates
|
|
|
|
// set false if unsure
|
2016-10-11 08:37:54 +03:00
|
|
|
$cascade_truncates = false;
|
2014-02-05 10:10:05 +02:00
|
|
|
|
|
|
|
return new PHPUnit_Extensions_Database_Operation_Composite(array(
|
2016-10-11 08:37:54 +03:00
|
|
|
new PHPUnit_Extensions_Database_Operation_MySQL55Truncate($cascade_truncates),
|
2014-02-05 10:10:05 +02:00
|
|
|
PHPUnit_Extensions_Database_Operation_Factory::INSERT()
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @group Mail
|
|
|
|
**/
|
2016-10-11 08:37:54 +03:00
|
|
|
function test_prepare_course()
|
2014-02-05 10:10:05 +02:00
|
|
|
{
|
|
|
|
Minion_Task::factory(array('task' => 'prepare'))->execute();
|
|
|
|
$status = DB::select('status')->from('tasks')->where('letter_id', '=', '1')->and_where('client_id','=','1')->execute()->get('status');
|
|
|
|
$this->assertEquals(Model_Task::STATUS_PENDING, $status);
|
|
|
|
}
|
|
|
|
|
2016-10-11 08:37:54 +03:00
|
|
|
function test_send_course()
|
2014-02-05 10:10:05 +02:00
|
|
|
{
|
|
|
|
$status = DB::select('status')->from('tasks')->where('letter_id', '=', '1')->and_where('client_id','=','1')->execute()->get('status');
|
|
|
|
if (is_null($status))
|
|
|
|
{
|
|
|
|
DB::insert('tasks', array('letter_id', 'client_id', 'date', 'status'))->values(array('1','1',date('Y-m-d'), Model_Task::STATUS_PENDING))->execute();
|
|
|
|
}
|
|
|
|
Minion_Task::factory(array('task' => 'send'))->execute();
|
|
|
|
$status = DB::select('status')->from('tasks')->where('letter_id', '=', '1')->and_where('client_id','=','1')->execute()->get('status');
|
|
|
|
$this->assertEquals(Model_Task::STATUS_SENT, $status);
|
|
|
|
}
|
|
|
|
}
|