Skip to content

Commit

Permalink
unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tim4dev committed Sep 24, 2009
1 parent f255b72 commit 41af0df
Show file tree
Hide file tree
Showing 33 changed files with 119 additions and 56 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -1,6 +1,7 @@
*~
*.tmp
.buildpath
.project
.settings/
library/Zend/
tests/report/*
17 changes: 17 additions & 0 deletions .project
Expand Up @@ -5,6 +5,21 @@
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.wst.jsdt.core.javascriptValidator</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.wst.validation.validationbuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.dltk.core.scriptbuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>net.sourceforge.phpeclipse.parserbuilder</name>
<arguments>
Expand All @@ -13,5 +28,7 @@
</buildSpec>
<natures>
<nature>net.sourceforge.phpeclipse.phpnature</nature>
<nature>org.eclipse.php.core.PHPNature</nature>
<nature>org.eclipse.wst.jsdt.core.jsNature</nature>
</natures>
</projectDescription>
13 changes: 7 additions & 6 deletions application/controllers/WblogbookController.php
Expand Up @@ -298,7 +298,7 @@ function addAction()
Zend_Loader::loadClass('Other_ValidateDatetime');
$validator_datetime = new Other_ValidateDatetime();

$logDateCreate = trim($this->_request->getPost('logDateCreate'));
$logDateCreate = trim($this->_request->getPost('logDateCreate', date("Y-m-d H:i:s", time() ) ) );

if ( !$validator_datetime->isValid($logDateCreate) ) {
$this->view->amessages = array_merge($this->view->amessages, $validator_datetime->getMessages());
Expand Down Expand Up @@ -515,10 +515,10 @@ function modifyAction()
$this->view->aAllowedTags = $this->aAllowedTags;
}


function savetopdfAction()
/*
function saveToPdfAction()
{
/*
http://www.zfforums.com/zend-framework-components-13/mail-formats-search-14/pdf-utf8-bug-not-362.html#post1041
------------------------------
tim4dev
Expand Down Expand Up @@ -575,7 +575,8 @@ function savetopdfAction()
$page->drawText($text, 20, 20, "UTF-8");
// Save document as a new file or rewrite existing document
$pdf->save($fileName);*/
$pdf->save($fileName);
}

*/

}
10 changes: 8 additions & 2 deletions application/models/WbTmpTable.php
Expand Up @@ -807,9 +807,15 @@ public function getTotalSummaryMark()
}


/*
* Возвращает имя файла, куда будут выгружены записи для восстановления
*/
public function getFilenameToExportMarkFiles() {
return "webacula_restore_" . $this->jobidhash . ".tmp";
}

/**
* Экспорт помеченных записей в текстовый файл
*
* Экспорт помеченных записей в текстовый файл (для восстановления)
*/
function exportMarkFiles($dir)
{
Expand Down
2 changes: 1 addition & 1 deletion tests/application/bootstrap.php
@@ -1,6 +1,6 @@
<?php
/* Start output buffering */
ob_start();
//ob_start();

error_reporting( E_ALL | E_STRICT );
ini_set('display_startup_errors', 1);
Expand Down
6 changes: 3 additions & 3 deletions tests/application/controllers/AllTests.php
Expand Up @@ -15,9 +15,9 @@ public static function suite()
{
$suite = new PHPUnit_Framework_TestSuite('Webacula Test Suite - Controllers');
$suite->addTestSuite('IndexControllerTest');
//$suite->addTestSuite('DirectorControllerTest');
//$suite->addTestSuite('JobControllerTest');
//$suite->addTestSuite('ChartControllerTest');
/*$suite->addTestSuite('DirectorControllerTest');
$suite->addTestSuite('JobControllerTest');
$suite->addTestSuite('ChartControllerTest');*/
return $suite;
}
}
4 changes: 3 additions & 1 deletion tests/application/models/AllTests.php
@@ -1,5 +1,6 @@
<?php
require_once dirname(__FILE__) . '/WbTmpTableTest.php';
require_once dirname(__FILE__) . '/WblogbookTest.php';

class ModelsAllTests
{
Expand All @@ -11,7 +12,8 @@ public static function main()
public static function suite()
{
$suite = new PHPUnit_Framework_TestSuite('Webacula Test Suite - Models');
$suite->addTestSuite('WbTmpTableTest');
//$suite->addTestSuite('WbTmpTableTest');
$suite->addTestSuite('WblogbookTest');
return $suite;
}
}
39 changes: 0 additions & 39 deletions tests/application/models/Copy_Of_WbTmpTableTest.php

This file was deleted.

7 changes: 7 additions & 0 deletions tests/application/models/WbTmpTableTest.php
Expand Up @@ -97,6 +97,13 @@ public function testMarkDir() {
$ares['total_files'] . " failed");
}

function testExportMarkFiles() {
print "\n".__CLASS__."\t".__FUNCTION__.' ';
$ares = $this->WbTmpTable->exportMarkFiles('/tmp');
$this->assertTrue( ( $ares['result'] && ($ares['count'] == 3607) ), 'error export marked files');
unlink( '/tmp/'.$this->WbTmpTable->getFilenameToExportMarkFiles() );
}

public function testUnMarkDir() {
print "\n".__CLASS__."\t".__FUNCTION__.' ';
$this->WbTmpTable->markDir("/tmp/webacula/test/1/0 Каталог'tmp/", 0);
Expand Down
65 changes: 65 additions & 0 deletions tests/application/models/WblogbookTest.php
@@ -0,0 +1,65 @@
<?php

require_once APPLICATION_PATH . '/models/Wblogbook.php';
require_once 'PHPUnit/Framework/TestCase.php';

class WblogbookTest extends PHPUnit_Framework_TestCase {

private $logbook;

/**
* Prepares the environment before running a test.
*/
protected function setUp() {
parent::setUp ();
$this->logbook = new wbLogBook();
}

/**
* Cleans up the environment after running a test.
*/
protected function tearDown() {
$this->logbook = null;
parent::tearDown();
}

/**
* Constructs the test case.
*/
public function __construct() {
// empty
}

public function testIndex() {
print "\n".__CLASS__."\t".__FUNCTION__.' ';
$ret = $this->logbook->IndexLogBook(null, null, null);
$result = $ret->fetchAll();
$this->assertGreaterThan(3, sizeof($result), 'error select logbook');
}

public function testAddRecord() {
print "\n".__CLASS__."\t".__FUNCTION__.' ';
$data = array(
'logDateCreate' => date("Y-m-d H:i:s", time() ),
'logTxt' => 'PHPUnit test testAddRecord',
'logTypeId' => 20
);
$id = $this->logbook->insert($data); // возвращает id вставленной записи
$this->assertGreaterThan(3, $id, 'error insert record to logbook');
}

public function testUpdateRecord() {
print "\n".__CLASS__."\t".__FUNCTION__.' ';
$data = array(
'logDateCreate' => date('Y-m-d H:i:s', time()-300),
'logDateLast' => date('Y-m-d H:i:s', time()),
'logTypeId' => 30,
'logTxt' => 'PHPUnit test testUpdateRecord',
'logIsDel' => 0
);
$where = $this->logbook->getAdapter()->quoteInto('logId = ?', 6);
$res = $this->logbook->update($data, $where); // возвращает кол-во измененных записей
$this->assertEquals(1, $res, 'error update record to logbook');
}

}
4 changes: 2 additions & 2 deletions tests/phpunit.xml
Expand Up @@ -6,13 +6,13 @@
convertWarningsToExceptions="true"
stopOnFailure="true"
syntaxCheck="true">
<!--
<!--
<testsuite name="Webacula Test Suite">
<directory>./</directory>
</testsuite>
<logging>
<log type="coverage-html" target="./report" charset="UTF-8" yui="true" highlight="true" lowUpperBound="35" highLowerBound="70"/>
</logging>
-->
-->
</phpunit>
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
5 changes: 3 additions & 2 deletions regress/prepare.sh → tests/prepare_tests/prepare.sh
Expand Up @@ -12,6 +12,7 @@ fi
BACULADIR="etc/bacula"
TMPDIR="/tmp/webacula"
BASEDIR=`pwd`
INSTALL_DIR="../../install/"

#########################################################
# Function
Expand Down Expand Up @@ -113,7 +114,7 @@ cd ${BASEDIR}
sh ./bacula_mysql_make_tables
sh ./bacula_sqlite_make_tables

cd ../install/
cd ${INSTALL_DIR}

sh ./webacula_mysql_create_database.sh
sh ./webacula_mysql_make_tables.sh
Expand All @@ -122,7 +123,7 @@ sh ./webacula_postgresql_make_tables.sh
sh ./webacula_sqlite_create_database.sh "/tmp/webacula/sqlite/webacula.db"
chmod a+rwx /tmp/webacula/sqlite

cd -
cd ${BASEDIR}


my_log "Testing Configuration Files ..."
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 2 additions & 0 deletions todo
@@ -1,3 +1,5 @@

префикс _PREFIX_RECENT не юзается в wbtmptable

test подключения языковых файлов

0 comments on commit 41af0df

Please sign in to comment.