Alternc  latest
Alternc logiel libre pour l'h├ębergement
 All Classes Namespaces Files Functions Variables Pages
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 ()
 m_action::do_action More...
 
 testChmod ()
 m_action::chmod More...
 
 testCreate_file ()
 m_action::create_file More...
 
 testCreate_dir ()
 m_action::create_dir More...
 
 testFix_user ()
 m_action::fix_user More...
 
 testFix_dir ()
 m_action::fix_dir More...
 
 testFix_file ()
 m_action::fix_file More...
 
 testDel ()
 m_action::del More...
 
 testMove ()
 m_action::move More...
 
 testArchive ()
 m_action::archive More...
 
 testSet ()
 m_action::set More...
 
 testGet_old ()
 m_action::get_old More...
 
 testPurge ()
 m_action::purge More...
 
 testGet_action ()
 m_action::get_action More...
 
 testBegin ($action)
 m_action::begin testGet_action More...
 
 testFinish ($action)
 m_action::finish testGet_action More...
 
 testReset_job ($action)
 m_action::reset_job testGet_action More...
 
 testGet_job ()
 m_action::get_job More...
 
 testCancel ($variable)
 m_action::cancel 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

AlterncTest::getConnection ( )
inherited
Returns
PHPUnit_Extensions_Database_DB_IDatabaseConnection

Definition at line 11 of file AlterncTest.php.

References $database, $password, and $user.

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

12  {
13  global $database,$user,$password;
14  $pdo = new PDO('mysql:dbname='.$database.';host=127.0.0.1',$user,$password);
15  return $this->createDefaultDBConnection($pdo);
16  }
$user
Definition: bootstrap.php:84
foreach(array(ALTERNC_MAIL, ALTERNC_HTML, ALTERNC_LOGS) as $crdir) $database
Definition: bootstrap.php:83
$password
Definition: bootstrap.php:85
m_actionTest::getDataSet ( )
Returns
PHPUnit_Extensions_Database_DataSet_IDataSet

Definition at line 20 of file m_actionTest.php.

References $list.

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
AlterncTest::loadDataSet (   $fileList)
inherited
Parameters
string$fileList
Returns
Exceptions
Exception

Definition at line 24 of file AlterncTest.php.

References PHPUNIT_DATASETS_PATH.

Referenced by testPurge(), and m_variablesTest\testVariable_update().

25  {
26  if (empty($fileList)) {
27  throw new \Exception("No files specified");
28  }
29  if( !is_array($fileList)){
30  $fileList = array($fileList);
31  }
32  $datasetList = array();
33  foreach ($fileList as $file_name) {
34  $file = PHPUNIT_DATASETS_PATH."/$file_name";
35  if( !is_file($file) ){
36  throw new \Exception("missing $file");
37  }
38  $dataSet = new PHPUnit_Extensions_Database_DataSet_YamlDataSet($file);
39  $datasetList[] = $dataSet;
40  }
41  $compositeDataSet = new PHPUnit_Extensions_Database_DataSet_CompositeDataSet($datasetList);
42  return $dataSet;
43  }
const PHPUNIT_DATASETS_PATH
Definition: bootstrap.php:20
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
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  }
m_actionTest::testArchive ( )

m_action::archive

Definition at line 148 of file m_actionTest.php.

References AlterncTest\getConnection().

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

m_action::begin testGet_action

Definition at line 197 of file m_actionTest.php.

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

m_action::cancel testGet_action

Definition at line 244 of file m_actionTest.php.

References AlterncTest\getConnection().

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  }
m_actionTest::testChmod ( )

m_action::chmod

Definition at line 76 of file m_actionTest.php.

References AlterncTest\getConnection().

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

m_action::create_dir

Definition at line 94 of file m_actionTest.php.

References AlterncTest\getConnection().

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

m_action::create_file

Definition at line 85 of file m_actionTest.php.

References AlterncTest\getConnection().

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

m_action::del

Definition at line 130 of file m_actionTest.php.

References AlterncTest\getConnection().

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

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  }
m_actionTest::testFinish (   $action)

m_action::finish testGet_action

Definition at line 206 of file m_actionTest.php.

References AlterncTest\getConnection().

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  }
m_actionTest::testFix_dir ( )

m_action::fix_dir

Definition at line 112 of file m_actionTest.php.

References AlterncTest\getConnection().

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

m_action::fix_file

Definition at line 121 of file m_actionTest.php.

References AlterncTest\getConnection().

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

m_action::fix_user

Definition at line 103 of file m_actionTest.php.

References AlterncTest\getConnection().

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

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  }
m_actionTest::testGet_job ( )

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  }
m_actionTest::testGet_old ( )

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  }
m_actionTest::testMove ( )

m_action::move

Definition at line 139 of file m_actionTest.php.

References AlterncTest\getConnection().

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  }
m_actionTest::testPurge ( )

m_action::purge

Definition at line 175 of file m_actionTest.php.

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

175  {
176  $result = $this->object->purge();
177  $this->assertEquals(0, $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:24
m_actionTest::testReset_job (   $action)

m_action::reset_job testGet_action

Definition at line 220 of file m_actionTest.php.

References AlterncTest\getConnection().

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  }
m_actionTest::testSet ( )

m_action::set

Definition at line 157 of file m_actionTest.php.

References AlterncTest\getConnection(), and null.

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  }
PR null
Definition: lang-css.js:1

Member Data Documentation

m_actionTest::$object
protected

Definition at line 11 of file m_actionTest.php.

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

Definition at line 14 of file m_actionTest.php.

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

Definition at line 13 of file m_actionTest.php.

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: