Alternc  latest
Alternc logiel libre pour l'hébergement
m_actionTest Class Reference

Generated by PHPUnit_SkeletonGenerator 1.2.1 on 2014-03-13 at 15:55:58. More...

+ Inheritance diagram for m_actionTest:

Public Member Functions

 getDataSet ()
 
 testDo_action ()
 @covers m_action::do_action More...
 
 testChmod ()
 @covers m_action::chmod More...
 
 testCreate_file ()
 @covers m_action::create_file More...
 
 testCreate_dir ()
 @covers m_action::create_dir More...
 
 testFix_user ()
 @covers m_action::fix_user More...
 
 testFix_dir ()
 @covers m_action::fix_dir More...
 
 testFix_file ()
 @covers m_action::fix_file More...
 
 testDel ()
 @covers m_action::del More...
 
 testMove ()
 @covers m_action::move More...
 
 testArchive ()
 @covers m_action::archive More...
 
 testSet ()
 @covers m_action::set More...
 
 testGet_old ()
 @covers m_action::get_old More...
 
 testPurge ()
 @covers m_action::purge More...
 
 testGet_action ()
 @covers m_action::get_action More...
 
 testBegin ($action)
 @covers m_action::begin @depends testGet_action More...
 
 testFinish ($action)
 @covers m_action::finish @depends testGet_action More...
 
 testReset_job ($action)
 @covers m_action::reset_job @depends testGet_action More...
 
 testGet_job ()
 @covers m_action::get_job More...
 
 testCancel ($variable)
 @covers m_action::cancel @depends testGet_action More...
 
 getConnection ()
 
 loadDataSet ($fileList)
 

Public Attributes

const TEST_FILE = "/tmp/phpunit-actionTest-file"
 
const TEST_DIR = "/tmp/phpunit-actionTest-dir"
 
const TEST_UID = 999
 

Protected Member Functions

 setUp ()
 Sets up the fixture, for example, opens a network connection. More...
 
 tearDown ()
 Tears down the fixture, for example, closes a network connection. More...
 

Protected Attributes

 $object
 

Detailed Description

Generated by PHPUnit_SkeletonGenerator 1.2.1 on 2014-03-13 at 15:55:58.

Definition at line 6 of file m_actionTest.php.

Member Function Documentation

◆ getConnection()

AlterncTest::getConnection ( )
inherited
Returns
PHPUnit_Extensions_Database_DB_IDatabaseConnection

Definition at line 18 of file AlterncTest.php.

19  {
20  global $database,$user,$password;
21  $pdo = new PDO('mysql:dbname='.$database.';host=127.0.0.1',$user,$password);
22  return $this->createDefaultDBConnection($pdo);
23  }
foreach(array(ALTERNC_MAIL, ALTERNC_HTML, ALTERNC_LOGS) as $crdir) $database
Definition: bootstrap.php:83
$user
Definition: bootstrap.php:84
$password
Definition: bootstrap.php:85

References $database, $password, and $user.

Referenced by testArchive(), testCancel(), testChmod(), testCreate_dir(), testCreate_file(), testDel(), testFinish(), testFix_dir(), testFix_file(), testFix_user(), testMove(), testPurge(), testReset_job(), and testSet().

◆ getDataSet()

m_actionTest::getDataSet ( )
Returns
PHPUnit_Extensions_Database_DataSet_IDataSet

Definition at line 20 of file m_actionTest.php.

20  {
21 
22  $list = array(
23  "testPurge" => "actions-purgeable.yml",
24  "testGet_action" => "actions-purgeable.yml",
25  "testGet_old" => "actions-purgeable.yml",
26  "testFinish" => "actions-purgeable.yml",
27  "testReset_job" => "actions-began.yml",
28  "testGet_job" => "actions-ready.yml",
29  "testCancel" => "actions-purgeable.yml",
30  "default" => "actions-purgeable.yml"
31  );
32  if (isset($list[$this->getName()])) {
33  $dataset_file = $list[$this->getName()];
34  } else {
35  $dataset_file = "actions-empty.yml";
36  }
37  return parent::loadDataSet($dataset_file);
38  }
$list
Show a list of all found log files for an account and allow to see / tail / download them.
Definition: logs_list.php:30

References $list.

◆ loadDataSet()

AlterncTest::loadDataSet (   $fileList)
inherited
Parameters
string$fileList
Returns
\PHPUnit_Extensions_Database_DataSet_YamlDataSet
Exceptions

Definition at line 31 of file AlterncTest.php.

32  {
33  if (empty($fileList)) {
34  throw new \Exception("No files specified");
35  }
36  if( !is_array($fileList)){
37  $fileList = array($fileList);
38  }
39  $datasetList = array();
40  foreach ($fileList as $file_name) {
41  $file = PHPUNIT_DATASETS_PATH."/$file_name";
42  if( !is_file($file) ){
43  throw new \Exception("missing $file");
44  }
45  $dataSet = new YamlDataSet($file);
46  $datasetList[] = $dataSet;
47  }
48  $compositeDataSet = new CompositeDataSet($datasetList);
49  return $dataSet;
50  }
const PHPUNIT_DATASETS_PATH
Definition: bootstrap.php:20

References PHPUNIT_DATASETS_PATH.

Referenced by testPurge().

◆ setUp()

m_actionTest::setUp ( )
protected

Sets up the fixture, for example, opens a network connection.

This method is called before a test is executed.

Definition at line 44 of file m_actionTest.php.

44  {
45  parent::setUp();
46  $this->object = new m_action;
47  }
This class manage actions to be performed on the file system on behalf of alternc Classes It primary ...
Definition: m_action.php:28

◆ tearDown()

m_actionTest::tearDown ( )
protected

Tears down the fixture, for example, closes a network connection.

This method is called after a test is executed.

Definition at line 53 of file m_actionTest.php.

53  {
54  global $L_INOTIFY_DO_ACTION;
55  parent::tearDown();
56  // Removes flag file eventually created
57  if (is_file($L_INOTIFY_DO_ACTION)) {
58  unlink($L_INOTIFY_DO_ACTION);
59  }
60  }

◆ testArchive()

m_actionTest::testArchive ( )

@covers m_action::archive

Definition at line 148 of file m_actionTest.php.

148  {
149  $result = $this->object->archive(self::TEST_DIR);
150  $this->assertTrue($result);
151  $this->assertEquals(1, $this->getConnection()->getRowCount('actions'));
152  }

References AlterncTest\getConnection().

◆ testBegin()

m_actionTest::testBegin (   $action)

@covers m_action::begin @depends testGet_action

Definition at line 197 of file m_actionTest.php.

197  {
198  $result = $this->object->begin($action["id"]);
199  $this->assertTrue($result);
200  }

◆ testCancel()

m_actionTest::testCancel (   $variable)

@covers m_action::cancel @depends testGet_action

Definition at line 244 of file m_actionTest.php.

244  {
245  $result = $this->object->cancel($variable["id"]);
246  $this->assertTrue($result);
247  $queryTable = $this->getConnection()->createQueryTable(
248  'actions', 'SELECT * FROM actions WHERE DAY(end) = DAY(NOW())'
249  );
250  $row_count = $queryTable->getRowCount();
251  $this->assertEquals(1, $row_count);
252  }

References AlterncTest\getConnection().

◆ testChmod()

m_actionTest::testChmod ( )

@covers m_action::chmod

Definition at line 76 of file m_actionTest.php.

76  {
77  $result = $this->object->chmod(self::TEST_FILE, 0777,"phpunit");
78  $this->assertEquals(1, $this->getConnection()->getRowCount('actions'));
79 
80  }

References AlterncTest\getConnection().

◆ testCreate_dir()

m_actionTest::testCreate_dir ( )

@covers m_action::create_dir

Definition at line 94 of file m_actionTest.php.

94  {
95  $result = $this->object->create_dir(self::TEST_FILE);
96  $this->assertTrue($result);
97  $this->assertEquals(1, $this->getConnection()->getRowCount('actions'));
98  }

References AlterncTest\getConnection().

◆ testCreate_file()

m_actionTest::testCreate_file ( )

@covers m_action::create_file

Definition at line 85 of file m_actionTest.php.

85  {
86  $result = $this->object->create_file(self::TEST_FILE, "phpunit");
87  $this->assertTrue($result);
88  $this->assertEquals(1, $this->getConnection()->getRowCount('actions'));
89  }

References AlterncTest\getConnection().

◆ testDel()

m_actionTest::testDel ( )

@covers m_action::del

Definition at line 130 of file m_actionTest.php.

130  {
131  $result = $this->object->del(self::TEST_DIR);
132  $this->assertTrue($result);
133  $this->assertEquals(1, $this->getConnection()->getRowCount('actions'));
134  }

References AlterncTest\getConnection().

◆ testDo_action()

m_actionTest::testDo_action ( )

@covers m_action::do_action

Definition at line 65 of file m_actionTest.php.

65  {
66  global $L_INOTIFY_DO_ACTION;
67  file_put_contents("/tmp/log_fser", "hello world from fser");
68  $result = $this->object->do_action();
69  $this->assertTrue($result);
70  $this->assertFileExists($L_INOTIFY_DO_ACTION);
71  }

◆ testFinish()

m_actionTest::testFinish (   $action)

@covers m_action::finish @depends testGet_action

Definition at line 206 of file m_actionTest.php.

206  {
207  $result = $this->object->finish($action["id"]);
208  $this->assertTrue($result);
209  $queryTable = $this->getConnection()->createQueryTable(
210  'actions', 'SELECT * FROM actions WHERE DAY(end) = DAY(NOW())'
211  );
212  $row_count = $queryTable->getRowCount();
213  $this->assertEquals(1, $row_count);
214  }

References AlterncTest\getConnection().

◆ testFix_dir()

m_actionTest::testFix_dir ( )

@covers m_action::fix_dir

Definition at line 112 of file m_actionTest.php.

112  {
113  $result = $this->object->fix_dir(self::TEST_DIR);
114  $this->assertTrue($result);
115  $this->assertEquals(1, $this->getConnection()->getRowCount('actions'));
116  }

References AlterncTest\getConnection().

◆ testFix_file()

m_actionTest::testFix_file ( )

@covers m_action::fix_file

Definition at line 121 of file m_actionTest.php.

121  {
122  $result = $this->object->fix_file(self::TEST_FILE);
123  $this->assertTrue($result);
124  $this->assertEquals(1, $this->getConnection()->getRowCount('actions'));
125  }

References AlterncTest\getConnection().

◆ testFix_user()

m_actionTest::testFix_user ( )

@covers m_action::fix_user

Definition at line 103 of file m_actionTest.php.

103  {
104  $result = $this->object->fix_user(self::TEST_UID);
105  $this->assertTrue($result);
106  $this->assertEquals(1, $this->getConnection()->getRowCount('actions'));
107  }

References AlterncTest\getConnection().

◆ testGet_action()

m_actionTest::testGet_action ( )

@covers m_action::get_action

Definition at line 186 of file m_actionTest.php.

186  {
187  $result = $this->object->get_action();
188  $this->assertTrue(is_array($result));
189  $this->assertCount(1, $result);
190  return current($result);
191  }

◆ testGet_job()

m_actionTest::testGet_job ( )

@covers m_action::get_job

Definition at line 234 of file m_actionTest.php.

234  {
235  $result = $this->object->get_job();
236  $this->assertTrue(is_array($result));
237  $this->assertCount(1, $result);
238  }

◆ testGet_old()

m_actionTest::testGet_old ( )

@covers m_action::get_old

Definition at line 167 of file m_actionTest.php.

167  {
168  $result = $this->object->get_old();
169  $this->assertEquals(1, $result);
170  }

◆ testMove()

m_actionTest::testMove ( )

@covers m_action::move

Definition at line 139 of file m_actionTest.php.

139  {
140  $result = $this->object->move(self::TEST_FILE, self::TEST_DIR);
141  $this->assertTrue($result);
142  $this->assertEquals(1, $this->getConnection()->getRowCount('actions'));
143  }

References AlterncTest\getConnection().

◆ testPurge()

m_actionTest::testPurge ( )

@covers m_action::purge

Definition at line 175 of file m_actionTest.php.

175  {
176  $result = $this->object->purge();
177  $this->assertEquals(1, $result);
178  $expectedTable = $this->loadDataSet("actions-empty.yml")->getTable("actions");
179  $currentTable = $this->getConnection()->createQueryTable('actions', 'SELECT * FROM actions');
180  $this->assertTablesEqual($expectedTable, $currentTable);
181  }
loadDataSet($fileList)
Definition: AlterncTest.php:31

References AlterncTest\getConnection(), and AlterncTest\loadDataSet().

◆ testReset_job()

m_actionTest::testReset_job (   $action)

@covers m_action::reset_job @depends testGet_action

Definition at line 220 of file m_actionTest.php.

220  {
221  $result = $this->object->reset_job($action["id"]);
222  $this->assertTrue($result);
223  $queryTable = $this->getConnection()->createQueryTable(
224  'actions', 'SELECT * FROM actions WHERE end = 0 AND begin = 0 AND status = 0'
225  );
226  $this->assertEquals(1, $queryTable->getRowCount());
227  }

References AlterncTest\getConnection().

◆ testSet()

m_actionTest::testSet ( )

@covers m_action::set

Definition at line 157 of file m_actionTest.php.

157  {
158  // We test only failure, other methods cover success
159  $result = $this->object->set(null, null, null);
160  $this->assertFalse($result);
161  $this->assertEquals(0, $this->getConnection()->getRowCount('actions'));
162  }

References AlterncTest\getConnection().

Member Data Documentation

◆ $object

m_actionTest::$object
protected

Definition at line 11 of file m_actionTest.php.

◆ TEST_DIR

const m_actionTest::TEST_DIR = "/tmp/phpunit-actionTest-dir"

Definition at line 14 of file m_actionTest.php.

◆ TEST_FILE

const m_actionTest::TEST_FILE = "/tmp/phpunit-actionTest-file"

Definition at line 13 of file m_actionTest.php.

◆ TEST_UID

const m_actionTest::TEST_UID = 999

Definition at line 15 of file m_actionTest.php.


The documentation for this class was generated from the following file: