[enh] Adds bureau/m_action testing
This commit is contained in:
parent
251d556c4a
commit
ae490904ea
|
@ -0,0 +1,10 @@
|
||||||
|
actions:
|
||||||
|
-
|
||||||
|
id: 999
|
||||||
|
type: "file"
|
||||||
|
parameters: "phpunit"
|
||||||
|
creation: "2000-01-01 00:00:00"
|
||||||
|
begin: "2020-12-31 23:59:58"
|
||||||
|
end: "2020-12-31 23:59:59"
|
||||||
|
user: "phpunit"
|
||||||
|
status: 0
|
|
@ -0,0 +1 @@
|
||||||
|
actions:
|
|
@ -0,0 +1,10 @@
|
||||||
|
actions:
|
||||||
|
-
|
||||||
|
id: 999
|
||||||
|
type: "file"
|
||||||
|
parameters: "phpunit"
|
||||||
|
creation: "2000-01-01 00:00:00"
|
||||||
|
begin: "0000-00-00 00:00:00"
|
||||||
|
end: "0000-00-00 00:00:00"
|
||||||
|
user: "phpunit"
|
||||||
|
status: 0
|
|
@ -0,0 +1,10 @@
|
||||||
|
actions:
|
||||||
|
-
|
||||||
|
id: 999
|
||||||
|
type: "file"
|
||||||
|
parameters: "phpunit"
|
||||||
|
creation: "2000-01-01 00:00:00"
|
||||||
|
begin: "2020-12-31 23:59:58"
|
||||||
|
end: "0000-00-00 00:00:00"
|
||||||
|
user: "phpunit"
|
||||||
|
status: 0
|
|
@ -1,20 +1,47 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generated by PHPUnit_SkeletonGenerator 1.2.1 on 2014-03-13 at 15:55:58.
|
* Generated by PHPUnit_SkeletonGenerator 1.2.1 on 2014-03-13 at 15:55:58.
|
||||||
*/
|
*/
|
||||||
class m_actionTest extends PHPUnit_Framework_TestCase
|
class m_actionTest extends AlterncTest {
|
||||||
{
|
|
||||||
/**
|
/**
|
||||||
* @var m_action
|
* @var m_action
|
||||||
*/
|
*/
|
||||||
protected $object;
|
protected $object;
|
||||||
|
|
||||||
|
const TEST_FILE = "/tmp/phpunit-actionTest-file";
|
||||||
|
const TEST_DIR = "/tmp/phpunit-actionTest-dir";
|
||||||
|
const TEST_UID = 999;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return PHPUnit_Extensions_Database_DataSet_IDataSet
|
||||||
|
*/
|
||||||
|
public function getDataSet() {
|
||||||
|
|
||||||
|
$list = array(
|
||||||
|
"testPurge" => "actions-purgeable.yml",
|
||||||
|
"testGet_action" => "actions-purgeable.yml",
|
||||||
|
"testGet_old" => "actions-purgeable.yml",
|
||||||
|
"testFinish" => "actions-purgeable.yml",
|
||||||
|
"testReset_job" => "actions-began.yml",
|
||||||
|
"testGet_job" => "actions-ready.yml",
|
||||||
|
"testCancel" => "actions-purgeable.yml",
|
||||||
|
"default" => "actions-purgeable.yml"
|
||||||
|
);
|
||||||
|
if (isset($list[$this->getName()])) {
|
||||||
|
$dataset_file = $list[$this->getName()];
|
||||||
|
} else {
|
||||||
|
$dataset_file = "actions-empty.yml";
|
||||||
|
}
|
||||||
|
return parent::loadDataSet($dataset_file);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets up the fixture, for example, opens a network connection.
|
* Sets up the fixture, for example, opens a network connection.
|
||||||
* This method is called before a test is executed.
|
* This method is called before a test is executed.
|
||||||
*/
|
*/
|
||||||
protected function setUp()
|
protected function setUp() {
|
||||||
{
|
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
$this->object = new m_action;
|
$this->object = new m_action;
|
||||||
}
|
}
|
||||||
|
@ -23,224 +50,195 @@ class m_actionTest extends PHPUnit_Framework_TestCase
|
||||||
* Tears down the fixture, for example, closes a network connection.
|
* Tears down the fixture, for example, closes a network connection.
|
||||||
* This method is called after a test is executed.
|
* This method is called after a test is executed.
|
||||||
*/
|
*/
|
||||||
protected function tearDown()
|
protected function tearDown() {
|
||||||
{
|
global $L_INOTIFY_DO_ACTION;
|
||||||
parent::tearDown();
|
parent::tearDown();
|
||||||
|
// Removes flag file eventually created
|
||||||
|
if (is_file($L_INOTIFY_DO_ACTION)) {
|
||||||
|
unlink($L_INOTIFY_DO_ACTION);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers m_action::do_action
|
* @covers m_action::do_action
|
||||||
* @todo Implement testDo_action().
|
|
||||||
*/
|
*/
|
||||||
public function testDo_action()
|
public function testDo_action() {
|
||||||
{
|
global $L_INOTIFY_DO_ACTION;
|
||||||
// Remove the following lines when you implement this test.
|
$result = $this->object->do_action();
|
||||||
$this->markTestIncomplete(
|
$this->assertTrue($result);
|
||||||
'This test has not been implemented yet.'
|
$this->assertFileExists($L_INOTIFY_DO_ACTION);
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers m_action::create_file
|
* @covers m_action::create_file
|
||||||
* @todo Implement testCreate_file().
|
|
||||||
*/
|
*/
|
||||||
public function testCreate_file()
|
public function testCreate_file() {
|
||||||
{
|
$result = $this->object->create_file(self::TEST_FILE, "phpunit");
|
||||||
// Remove the following lines when you implement this test.
|
$this->assertTrue($result);
|
||||||
$this->markTestIncomplete(
|
$this->assertEquals(1, $this->getConnection()->getRowCount('actions'));
|
||||||
'This test has not been implemented yet.'
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers m_action::create_dir
|
* @covers m_action::create_dir
|
||||||
* @todo Implement testCreate_dir().
|
|
||||||
*/
|
*/
|
||||||
public function testCreate_dir()
|
public function testCreate_dir() {
|
||||||
{
|
$result = $this->object->create_dir(self::TEST_FILE);
|
||||||
// Remove the following lines when you implement this test.
|
$this->assertTrue($result);
|
||||||
$this->markTestIncomplete(
|
$this->assertEquals(1, $this->getConnection()->getRowCount('actions'));
|
||||||
'This test has not been implemented yet.'
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers m_action::fix_user
|
* @covers m_action::fix_user
|
||||||
* @todo Implement testFix_user().
|
|
||||||
*/
|
*/
|
||||||
public function testFix_user()
|
public function testFix_user() {
|
||||||
{
|
$result = $this->object->fix_user(self::TEST_UID);
|
||||||
// Remove the following lines when you implement this test.
|
$this->assertTrue($result);
|
||||||
$this->markTestIncomplete(
|
$this->assertEquals(1, $this->getConnection()->getRowCount('actions'));
|
||||||
'This test has not been implemented yet.'
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers m_action::fix_dir
|
* @covers m_action::fix_dir
|
||||||
* @todo Implement testFix_dir().
|
|
||||||
*/
|
*/
|
||||||
public function testFix_dir()
|
public function testFix_dir() {
|
||||||
{
|
$result = $this->object->fix_dir(self::TEST_DIR);
|
||||||
// Remove the following lines when you implement this test.
|
$this->assertTrue($result);
|
||||||
$this->markTestIncomplete(
|
$this->assertEquals(1, $this->getConnection()->getRowCount('actions'));
|
||||||
'This test has not been implemented yet.'
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers m_action::fix_file
|
* @covers m_action::fix_file
|
||||||
* @todo Implement testFix_file().
|
|
||||||
*/
|
*/
|
||||||
public function testFix_file()
|
public function testFix_file() {
|
||||||
{
|
$result = $this->object->fix_file(self::TEST_FILE);
|
||||||
// Remove the following lines when you implement this test.
|
$this->assertTrue($result);
|
||||||
$this->markTestIncomplete(
|
$this->assertEquals(1, $this->getConnection()->getRowCount('actions'));
|
||||||
'This test has not been implemented yet.'
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers m_action::del
|
* @covers m_action::del
|
||||||
* @todo Implement testDel().
|
|
||||||
*/
|
*/
|
||||||
public function testDel()
|
public function testDel() {
|
||||||
{
|
$result = $this->object->del(self::TEST_DIR);
|
||||||
// Remove the following lines when you implement this test.
|
$this->assertTrue($result);
|
||||||
$this->markTestIncomplete(
|
$this->assertEquals(1, $this->getConnection()->getRowCount('actions'));
|
||||||
'This test has not been implemented yet.'
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers m_action::move
|
* @covers m_action::move
|
||||||
* @todo Implement testMove().
|
|
||||||
*/
|
*/
|
||||||
public function testMove()
|
public function testMove() {
|
||||||
{
|
$result = $this->object->move(self::TEST_FILE, self::TEST_DIR);
|
||||||
// Remove the following lines when you implement this test.
|
$this->assertTrue($result);
|
||||||
$this->markTestIncomplete(
|
$this->assertEquals(1, $this->getConnection()->getRowCount('actions'));
|
||||||
'This test has not been implemented yet.'
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers m_action::archive
|
* @covers m_action::archive
|
||||||
* @todo Implement testArchive().
|
|
||||||
*/
|
*/
|
||||||
public function testArchive()
|
public function testArchive() {
|
||||||
{
|
$result = $this->object->archive(self::TEST_DIR);
|
||||||
// Remove the following lines when you implement this test.
|
$this->assertTrue($result);
|
||||||
$this->markTestIncomplete(
|
$this->assertEquals(1, $this->getConnection()->getRowCount('actions'));
|
||||||
'This test has not been implemented yet.'
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers m_action::set
|
* @covers m_action::set
|
||||||
* @todo Implement testSet().
|
|
||||||
*/
|
*/
|
||||||
public function testSet()
|
public function testSet() {
|
||||||
{
|
// We test only failure, other methods cover success
|
||||||
// Remove the following lines when you implement this test.
|
$result = $this->object->set(null, null, null);
|
||||||
$this->markTestIncomplete(
|
$this->assertFalse($result);
|
||||||
'This test has not been implemented yet.'
|
$this->assertEquals(0, $this->getConnection()->getRowCount('actions'));
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers m_action::get_old
|
* @covers m_action::get_old
|
||||||
* @todo Implement testGet_old().
|
|
||||||
*/
|
*/
|
||||||
public function testGet_old()
|
public function testGet_old() {
|
||||||
{
|
$result = $this->object->get_old();
|
||||||
// Remove the following lines when you implement this test.
|
$this->assertEquals(1, $result);
|
||||||
$this->markTestIncomplete(
|
|
||||||
'This test has not been implemented yet.'
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers m_action::purge
|
* @covers m_action::purge
|
||||||
* @todo Implement testPurge().
|
|
||||||
*/
|
*/
|
||||||
public function testPurge()
|
public function testPurge() {
|
||||||
{
|
$result = $this->object->purge();
|
||||||
// Remove the following lines when you implement this test.
|
$this->assertEquals(0, $result);
|
||||||
$this->markTestIncomplete(
|
$expectedTable = $this->loadDataSet("actions-empty.yml")->getTable("actions");
|
||||||
'This test has not been implemented yet.'
|
$currentTable = $this->getConnection()->createQueryTable('actions', 'SELECT * FROM actions');
|
||||||
);
|
$this->assertTablesEqual($expectedTable, $currentTable);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers m_action::get_action
|
* @covers m_action::get_action
|
||||||
* @todo Implement testGet_action().
|
|
||||||
*/
|
*/
|
||||||
public function testGet_action()
|
public function testGet_action() {
|
||||||
{
|
$result = $this->object->get_action();
|
||||||
// Remove the following lines when you implement this test.
|
$this->assertTrue(is_array($result));
|
||||||
$this->markTestIncomplete(
|
$this->assertCount(1, $result);
|
||||||
'This test has not been implemented yet.'
|
return current($result);
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers m_action::begin
|
* @covers m_action::begin
|
||||||
* @todo Implement testBegin().
|
* @depends testGet_action
|
||||||
*/
|
*/
|
||||||
public function testBegin()
|
public function testBegin($action) {
|
||||||
{
|
$result = $this->object->begin($action["id"]);
|
||||||
// Remove the following lines when you implement this test.
|
$this->assertTrue($result);
|
||||||
$this->markTestIncomplete(
|
|
||||||
'This test has not been implemented yet.'
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers m_action::finish
|
* @covers m_action::finish
|
||||||
* @todo Implement testFinish().
|
* @depends testGet_action
|
||||||
*/
|
*/
|
||||||
public function testFinish()
|
public function testFinish($action) {
|
||||||
{
|
$result = $this->object->finish($action["id"]);
|
||||||
// Remove the following lines when you implement this test.
|
$this->assertTrue($result);
|
||||||
$this->markTestIncomplete(
|
$queryTable = $this->getConnection()->createQueryTable(
|
||||||
'This test has not been implemented yet.'
|
'actions', 'SELECT * FROM actions WHERE DAY(end) = DAY(NOW())'
|
||||||
);
|
);
|
||||||
|
$row_count = $queryTable->getRowCount();
|
||||||
|
$this->assertEquals(1, $row_count);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers m_action::reset_job
|
* @covers m_action::reset_job
|
||||||
* @todo Implement testReset_job().
|
* @depends testGet_action
|
||||||
*/
|
*/
|
||||||
public function testReset_job()
|
public function testReset_job($action) {
|
||||||
{
|
$result = $this->object->reset_job($action["id"]);
|
||||||
// Remove the following lines when you implement this test.
|
$this->assertTrue($result);
|
||||||
$this->markTestIncomplete(
|
$queryTable = $this->getConnection()->createQueryTable(
|
||||||
'This test has not been implemented yet.'
|
'actions', 'SELECT * FROM actions WHERE end = 0 AND begin = 0 AND status = 0'
|
||||||
);
|
);
|
||||||
|
$this->assertEquals(1, $queryTable->getRowCount());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
*
|
||||||
|
*
|
||||||
* @covers m_action::get_job
|
* @covers m_action::get_job
|
||||||
* @todo Implement testGet_job().
|
|
||||||
*/
|
*/
|
||||||
public function testGet_job()
|
public function testGet_job() {
|
||||||
{
|
$result = $this->object->get_job();
|
||||||
// Remove the following lines when you implement this test.
|
$this->assertTrue(is_array($result));
|
||||||
$this->markTestIncomplete(
|
$this->assertCount(1, $result);
|
||||||
'This test has not been implemented yet.'
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers m_action::cancel
|
* @covers m_action::cancel
|
||||||
* @todo Implement testCancel().
|
* @depends testGet_action
|
||||||
*/
|
*/
|
||||||
public function testCancel()
|
public function testCancel($variable) {
|
||||||
{
|
$result = $this->object->cancel($variable["id"]);
|
||||||
// Remove the following lines when you implement this test.
|
$this->assertTrue($result);
|
||||||
$this->markTestIncomplete(
|
$queryTable = $this->getConnection()->createQueryTable(
|
||||||
'This test has not been implemented yet.'
|
'actions', 'SELECT * FROM actions WHERE DAY(end) = DAY(NOW())'
|
||||||
);
|
);
|
||||||
|
$row_count = $queryTable->getRowCount();
|
||||||
|
$this->assertEquals(1, $row_count);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue