Commit ae490904 authored by alban's avatar alban
Browse files

[enh] Adds bureau/m_action testing

parent 251d556c
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
\ No newline at end of file
actions:
\ No newline at end of file
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
\ No newline at end of file
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
\ No newline at end of file
<?php
/**
* 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
*/
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.
* This method is called before a test is executed.
*/
protected function setUp()
{
protected function setUp() {
parent::setUp();
$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.
* This method is called after a test is executed.
*/
protected function tearDown()
{
protected function tearDown() {
global $L_INOTIFY_DO_ACTION;
parent::tearDown();
// Removes flag file eventually created
if (is_file($L_INOTIFY_DO_ACTION)) {
unlink($L_INOTIFY_DO_ACTION);
}
}
/**
* @covers m_action::do_action
* @todo Implement testDo_action().
*/
public function testDo_action()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
public function testDo_action() {
global $L_INOTIFY_DO_ACTION;
$result = $this->object->do_action();
$this->assertTrue($result);
$this->assertFileExists($L_INOTIFY_DO_ACTION);
}
/**
* @covers m_action::create_file
* @todo Implement testCreate_file().
*/
public function testCreate_file()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
public function testCreate_file() {
$result = $this->object->create_file(self::TEST_FILE, "phpunit");
$this->assertTrue($result);
$this->assertEquals(1, $this->getConnection()->getRowCount('actions'));
}
/**
* @covers m_action::create_dir
* @todo Implement testCreate_dir().
*/
public function testCreate_dir()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
public function testCreate_dir() {
$result = $this->object->create_dir(self::TEST_FILE);
$this->assertTrue($result);
$this->assertEquals(1, $this->getConnection()->getRowCount('actions'));
}
/**
* @covers m_action::fix_user
* @todo Implement testFix_user().
*/
public function testFix_user()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
public function testFix_user() {
$result = $this->object->fix_user(self::TEST_UID);
$this->assertTrue($result);
$this->assertEquals(1, $this->getConnection()->getRowCount('actions'));
}
/**
* @covers m_action::fix_dir
* @todo Implement testFix_dir().
*/
public function testFix_dir()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
public function testFix_dir() {
$result = $this->object->fix_dir(self::TEST_DIR);
$this->assertTrue($result);
$this->assertEquals(1, $this->getConnection()->getRowCount('actions'));
}
/**
* @covers m_action::fix_file
* @todo Implement testFix_file().
*/
public function testFix_file()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
public function testFix_file() {
$result = $this->object->fix_file(self::TEST_FILE);
$this->assertTrue($result);
$this->assertEquals(1, $this->getConnection()->getRowCount('actions'));
}
/**
* @covers m_action::del
* @todo Implement testDel().
*/
public function testDel()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
public function testDel() {
$result = $this->object->del(self::TEST_DIR);
$this->assertTrue($result);
$this->assertEquals(1, $this->getConnection()->getRowCount('actions'));
}
/**
* @covers m_action::move
* @todo Implement testMove().
*/
public function testMove()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
public function testMove() {
$result = $this->object->move(self::TEST_FILE, self::TEST_DIR);
$this->assertTrue($result);
$this->assertEquals(1, $this->getConnection()->getRowCount('actions'));
}
/**
* @covers m_action::archive
* @todo Implement testArchive().
*/
public function testArchive()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
public function testArchive() {
$result = $this->object->archive(self::TEST_DIR);
$this->assertTrue($result);
$this->assertEquals(1, $this->getConnection()->getRowCount('actions'));
}
/**
* @covers m_action::set
* @todo Implement testSet().
*/
public function testSet()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
public function testSet() {
// We test only failure, other methods cover success
$result = $this->object->set(null, null, null);
$this->assertFalse($result);
$this->assertEquals(0, $this->getConnection()->getRowCount('actions'));
}
/**
* @covers m_action::get_old
* @todo Implement testGet_old().
*/
public function testGet_old()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
public function testGet_old() {
$result = $this->object->get_old();
$this->assertEquals(1, $result);
}
/**
* @covers m_action::purge
* @todo Implement testPurge().
*/
public function testPurge()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
public function testPurge() {
$result = $this->object->purge();
$this->assertEquals(0, $result);
$expectedTable = $this->loadDataSet("actions-empty.yml")->getTable("actions");
$currentTable = $this->getConnection()->createQueryTable('actions', 'SELECT * FROM actions');
$this->assertTablesEqual($expectedTable, $currentTable);
}
/**
* @covers m_action::get_action
* @todo Implement testGet_action().
*/
public function testGet_action()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
public function testGet_action() {
$result = $this->object->get_action();
$this->assertTrue(is_array($result));
$this->assertCount(1, $result);
return current($result);
}
/**
* @covers m_action::begin
* @todo Implement testBegin().
* @depends testGet_action
*/
public function testBegin()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
public function testBegin($action) {
$result = $this->object->begin($action["id"]);
$this->assertTrue($result);
}
/**
* @covers m_action::finish
* @todo Implement testFinish().
* @depends testGet_action
*/
public function testFinish()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
public function testFinish($action) {
$result = $this->object->finish($action["id"]);
$this->assertTrue($result);
$queryTable = $this->getConnection()->createQueryTable(
'actions', 'SELECT * FROM actions WHERE DAY(end) = DAY(NOW())'
);
$row_count = $queryTable->getRowCount();
$this->assertEquals(1, $row_count);
}
/**
* @covers m_action::reset_job
* @todo Implement testReset_job().
* @depends testGet_action
*/
public function testReset_job()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
public function testReset_job($action) {
$result = $this->object->reset_job($action["id"]);
$this->assertTrue($result);
$queryTable = $this->getConnection()->createQueryTable(
'actions', 'SELECT * FROM actions WHERE end = 0 AND begin = 0 AND status = 0'
);
$this->assertEquals(1, $queryTable->getRowCount());
}
/**
*
*
* @covers m_action::get_job
* @todo Implement testGet_job().
*/
public function testGet_job()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
public function testGet_job() {
$result = $this->object->get_job();
$this->assertTrue(is_array($result));
$this->assertCount(1, $result);
}
/**
* @covers m_action::cancel
* @todo Implement testCancel().
* @depends testGet_action
*/
public function testCancel()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
public function testCancel($variable) {
$result = $this->object->cancel($variable["id"]);
$this->assertTrue($result);
$queryTable = $this->getConnection()->createQueryTable(
'actions', 'SELECT * FROM actions WHERE DAY(end) = DAY(NOW())'
);
$row_count = $queryTable->getRowCount();
$this->assertEquals(1, $row_count);
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment