From b439eef071e21026436be8fc67d1a07580dbc17d Mon Sep 17 00:00:00 2001 From: Eriksen Costa Paixão Date: Fri, 18 Sep 2009 20:32:59 +0000 Subject: [PATCH] by Eriksen: Refactoring no diretório {{{tests/}}}: --- ieducar/misc/build.xml | 176 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------------------------------------------------------------------- ieducar/phpunit.xml | 2 +- ieducar/tests/AllTests.php | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ ieducar/tests/FunctionalBaseTest.class.php | 50 +++++++++++++++++++++++++++----------------------- ieducar/tests/TestCollector.php | 201 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ieducar/tests/UnitBaseTest.class.php | 40 +++++++++++++++++----------------------- ieducar/tests/bootstrap.php | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ieducar/tests/functional/AllTests.php | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ ieducar/tests/functional/ServidorCategoriaNivelWebTest.class.php | 75 --------------------------------------------------------------------------- ieducar/tests/functional/ServidorCategoriaNivelWebTest.php | 83 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ieducar/tests/functional/ServidorMotivoAfastamentoWebTest.class.php | 89 ----------------------------------------------------------------------------------------- ieducar/tests/functional/ServidorMotivoAfastamentoWebTest.php | 88 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ieducar/tests/unit/AllTests.php | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ieducar/tests/unit/App/AllTests.php | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ieducar/tests/unit/App/Model/AllTests.php | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ ieducar/tests/unit/App/Service/AllTests.php | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ ieducar/tests/unit/ClsBancoTest.class.php | 65 ----------------------------------------------------------------- ieducar/tests/unit/ClsConfigItajaiTest.class.php | 75 --------------------------------------------------------------------------- ieducar/tests/unit/ClsPmieducarQuadroHorarioHorariosTest.class.php | 52 ---------------------------------------------------- ieducar/tests/unit/ClsPmieducarServidorAlocacaoTest.class.php | 52 ---------------------------------------------------- ieducar/tests/unit/Core/AllTests.php | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ieducar/tests/unit/Core/ClsBancoTest.php | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ieducar/tests/unit/Core/ClsConfigItajaiTest.php | 85 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ieducar/tests/unit/Core/ClsPmieducarQuadroHorarioHorariosTest.php | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ieducar/tests/unit/Core/ClsPmieducarServidorAlocacaoTest.php | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ieducar/tests/unit/CoreExt/AllTests.php | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ ieducar/tests/unit/CoreExt/CoreExt_ConfigTest.php | 145 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ieducar/tests/unit/CoreExt/CoreExt_Config_IniTest.php | 100 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ieducar/tests/unit/CoreExt_ConfigTest.class.php | 137 ----------------------------------------------------------------------------------------------------------------------------------------- ieducar/tests/unit/CoreExt_Config_IniTest.class.php | 89 ----------------------------------------------------------------------------------------- ieducar/tests/unit/FileStreamTest.class.php | 157 ------------------------------------------------------------------------------------------------------------------------------------------------------------- ieducar/tests/unit/Utils/AllTests.php | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ ieducar/tests/unit/Utils/FileStreamTest.php | 164 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 33 files changed, 1743 insertions(+), 927 deletions(-) create mode 100644 ieducar/tests/AllTests.php create mode 100644 ieducar/tests/TestCollector.php create mode 100644 ieducar/tests/bootstrap.php create mode 100644 ieducar/tests/functional/AllTests.php delete mode 100644 ieducar/tests/functional/ServidorCategoriaNivelWebTest.class.php create mode 100644 ieducar/tests/functional/ServidorCategoriaNivelWebTest.php delete mode 100644 ieducar/tests/functional/ServidorMotivoAfastamentoWebTest.class.php create mode 100644 ieducar/tests/functional/ServidorMotivoAfastamentoWebTest.php create mode 100644 ieducar/tests/unit/AllTests.php create mode 100644 ieducar/tests/unit/App/AllTests.php create mode 100644 ieducar/tests/unit/App/Model/AllTests.php create mode 100644 ieducar/tests/unit/App/Service/AllTests.php delete mode 100644 ieducar/tests/unit/ClsBancoTest.class.php delete mode 100644 ieducar/tests/unit/ClsConfigItajaiTest.class.php delete mode 100644 ieducar/tests/unit/ClsPmieducarQuadroHorarioHorariosTest.class.php delete mode 100644 ieducar/tests/unit/ClsPmieducarServidorAlocacaoTest.class.php create mode 100644 ieducar/tests/unit/Core/AllTests.php create mode 100644 ieducar/tests/unit/Core/ClsBancoTest.php create mode 100644 ieducar/tests/unit/Core/ClsConfigItajaiTest.php create mode 100644 ieducar/tests/unit/Core/ClsPmieducarQuadroHorarioHorariosTest.php create mode 100644 ieducar/tests/unit/Core/ClsPmieducarServidorAlocacaoTest.php create mode 100644 ieducar/tests/unit/CoreExt/AllTests.php create mode 100644 ieducar/tests/unit/CoreExt/CoreExt_ConfigTest.php create mode 100644 ieducar/tests/unit/CoreExt/CoreExt_Config_IniTest.php delete mode 100644 ieducar/tests/unit/CoreExt_ConfigTest.class.php delete mode 100644 ieducar/tests/unit/CoreExt_Config_IniTest.class.php delete mode 100644 ieducar/tests/unit/FileStreamTest.class.php create mode 100644 ieducar/tests/unit/Utils/AllTests.php create mode 100644 ieducar/tests/unit/Utils/FileStreamTest.php diff --git a/ieducar/misc/build.xml b/ieducar/misc/build.xml index 9e0b06d..cfa0ac1 100644 --- a/ieducar/misc/build.xml +++ b/ieducar/misc/build.xml @@ -1,27 +1,29 @@ - - - - + + + @@ -34,13 +36,54 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -54,33 +97,13 @@ - - - - - - - - - - - - - - - - - - - - - + @@ -91,37 +114,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -132,28 +124,34 @@ - - + - - + + + + + + + @@ -177,9 +175,9 @@ - + - + diff --git a/ieducar/phpunit.xml b/ieducar/phpunit.xml index 07c1c2f..f83dc34 100644 --- a/ieducar/phpunit.xml +++ b/ieducar/phpunit.xml @@ -4,5 +4,5 @@ - Configurações do PHPUnit. --> - + diff --git a/ieducar/tests/AllTests.php b/ieducar/tests/AllTests.php new file mode 100644 index 0000000..153dba5 --- /dev/null +++ b/ieducar/tests/AllTests.php @@ -0,0 +1,55 @@ + + * + * Este programa software livre; voc pode redistribu-lo e/ou modific-lo + * sob os termos da Licena Pblica Geral GNU conforme publicada pela Free + * Software Foundation; tanto a verso 2 da Licena, como (a seu critrio) + * qualquer verso posterior. + * + * Este programa distribudo na expectativa de que seja til, porm, SEM + * NENHUMA GARANTIA; nem mesmo a garantia implcita de COMERCIABILIDADE OU + * ADEQUAO A UMA FINALIDADE ESPECFICA. Consulte a Licena Pblica Geral + * do GNU para mais detalhes. + * + * Voc deve ter recebido uma cpia da Licena Pblica Geral do GNU junto + * com este programa; se no, escreva para a Free Software Foundation, Inc., no + * endereo 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. + * + * @author Eriksen Costa Paixo + * @category i-Educar + * @license @@license@@ + * @package Tests + * @since Arquivo disponvel desde a verso 1.1.0 + * @version $Id$ + */ + +require_once 'unit/AllTests.php'; +require_once 'functional/AllTests.php'; + +/** + * AllTests class. + * + * Arquivo de definio de sute para o projeto. + * + * @author Eriksen Costa Paixo + * @category i-Educar + * @license @@license@@ + * @package Tests + * @since Classe disponvel desde a verso 1.1.0 + * @version @@package_version@@ + */ +class AllTests +{ + public static function suite() + { + $suite = new PHPUnit_Framework_TestSuite('Sute de testes do projeto (unitrios e funcionais)'); + $suite->addTest(Unit_AllTests::suite()); + $suite->addTest(Functional_AllTests::suite()); + return $suite; + } +} \ No newline at end of file diff --git a/ieducar/tests/FunctionalBaseTest.class.php b/ieducar/tests/FunctionalBaseTest.class.php index ef24025..d51fb92 100644 --- a/ieducar/tests/FunctionalBaseTest.class.php +++ b/ieducar/tests/FunctionalBaseTest.class.php @@ -1,6 +1,6 @@ + * @category i-Educar + * @license @@license@@ + * @package FunctionalTests + * @since Arquivo disponvel desde a verso 1.0.1 + * @version $Id$ */ +require_once 'PHPUnit/Extensions/SeleniumTestCase.php'; + /** * FunctionBaseTest class. * * Contm as configuraes de acesso ao servidor Selenium RC, a conta de usurio * a ser utilizada no teste e alguns mtodos auxiliares. * - * Muda o diretrio atual para que os testes possam ser facilmente invocados - * em qualquer subdiretrio do sistema. - * * Abstrai o PHPUnit, diminuindo a dependncia de seu uso. Inclui a classe * de banco de dados para facilitar no tearDown de dados de teste. * - * @author Eriksen Costa Paixo - * @license http://creativecommons.org/licenses/GPL/2.0/legalcode.pt CC GNU GPL - * @package Test - * @since Classe disponvel desde a verso 1.0.1 - * @version $Id$ + * @author Eriksen Costa Paixo + * @category i-Educar + * @license http://creativecommons.org/licenses/GPL/2.0/legalcode.pt CC GNU GPL + * @package FunctionalTests + * @since Classe disponvel desde a verso 1.0.1 + * @version @@package_version@@ */ - -chdir(realpath(dirname(__FILE__) . '/../') . '/intranet'); -require_once 'PHPUnit/Extensions/SeleniumTestCase.php'; -require_once 'include/clsBanco.inc.php'; - -abstract class FunctionalBaseTest extends PHPUnit_Extensions_SeleniumTestCase { - - // Configuraes do Selenium RC +abstract class FunctionalBaseTest extends PHPUnit_Extensions_SeleniumTestCase +{ + // Configuraes do Selenium RC. static protected $slBrowserUrl = 'http://ieducar.local', $slBrowser = '*firefox', $slPort = 4444, $slHost = 'localhost'; - // Conta de usurio para testes funcionais + // Conta de usurio para testes funcionais. protected $slUsuarioLogin = 'admin', $slUsuarioSenha = 'admin'; - protected function setUp() { + protected function setUp() + { $this->setBrowser(self::$slBrowser); $this->setHost(self::$slHost); $this->setPort(self::$slPort); $this->setBrowserUrl(self::$slBrowserUrl); } - protected function doLogin() { + protected function doLogin() + { $this->open('/intranet'); $this->type('login', $this->slUsuarioLogin); $this->type('senha', $this->slUsuarioSenha); $this->clickAndWait("//input[@value='Entrar']"); } - protected function doLogout() { + protected function doLogout() + { $this->click("//img[@alt='Logout']"); } - -} +} \ No newline at end of file diff --git a/ieducar/tests/TestCollector.php b/ieducar/tests/TestCollector.php new file mode 100644 index 0000000..69bc356 --- /dev/null +++ b/ieducar/tests/TestCollector.php @@ -0,0 +1,201 @@ + + * + * Este programa software livre; voc pode redistribu-lo e/ou modific-lo + * sob os termos da Licena Pblica Geral GNU conforme publicada pela Free + * Software Foundation; tanto a verso 2 da Licena, como (a seu critrio) + * qualquer verso posterior. + * + * Este programa distribudo na expectativa de que seja til, porm, SEM + * NENHUMA GARANTIA; nem mesmo a garantia implcita de COMERCIABILIDADE OU + * ADEQUAO A UMA FINALIDADE ESPECFICA. Consulte a Licena Pblica Geral + * do GNU para mais detalhes. + * + * Voc deve ter recebido uma cpia da Licena Pblica Geral do GNU junto + * com este programa; se no, escreva para a Free Software Foundation, Inc., no + * endereo 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. + * + * @author Eriksen Costa Paixo + * @category i-Educar + * @license @@license@@ + * @package Tests + * @since Arquivo disponvel desde a verso 1.1.0 + * @version $Id$ + */ + +require_once 'PHPUnit/Framework.php'; +require_once 'PHPUnit/Runner/IncludePathTestCollector.php'; + +/** + * TestCollector abstract class. + * + * Classe abstrata que prov um ponto de extenso para classes de definio de + * sute de testes do PHPUnit (veja {@link Orga}) + * + * Ao estender corretamente essa classe, todos as classes de teste do diretrio + * da classe de definio de sute de testes sero adicionados sute, + * tornando desnecessrio a nessidade de usar os construtores de linguagem + * require e include para incluir esses arquivos. + * + * Para estender essa classe, basta informar o caminho para o arquivo da classe + * de definio da sute na varivel protegida $_file, exemplo: + * + * + * class App_Model_AllTests extends TestCollector + * { + * protected $_file = __FILE__; + * } + * + * + * Isso o suficiente para conseguir coletar todos os arquivos do diretrio. + * Para criar uma sute de testes com todas as classes de teste do diretrio, + * basta criar uma instncia da classe e chamar o mtodo addDirectoryTests(): + * + * + * public static function suite() + * { + * $instance = new self(); + * return $instance->createTestSuite('App_Model: testes unitrios') + * ->addDirectoryTests(); + * } + * + * + * Se a varivel de instncia $_name estiver sobrescrita, ela ser utilizada + * por padro caso o mtodo createTestSuite() seja chamado sem o parmetro nome. + * Dessa forma, basta chamar o mtodo addDirectoryTests(): + * + * + * protected $_name = 'App_model: testes unitrios'; + * + * public static function suite() + * { + * $instance = new self(); + * return $instance->addDirectoryTests(); + * } + * + * + * @author Eriksen Costa Paixo + * @category i-Educar + * @license @@license@@ + * @package Tests + * @since Classe disponvel desde a verso 1.1.0 + * @version @@package_version@@ + */ +abstract class TestCollector +{ + /** + * Caminho completo do arquivo da classe que estende TestCollector. + * @var string + */ + protected $_file = NULL; + + /** + * Diretrio onde residem os arquivos com as classes de teste. + * @var string + */ + protected $_dir = NULL; + + /** + * Nome da sute de testes. + * @var string + */ + protected $_name = ''; + + /** + * Uma instncia de PHPUnit_Framework_TestSuite. + * @var PHPUnit_Framework_TestSuite + */ + protected $_suite = NULL; + + /** + * Construtor. + * @return TestCollector + */ + public function __construct() + { + $this->_defineCurrentDir(); + } + + /** + * Cria um objeto PHPUnit_Framework_TestSuite com o nome passado como + * argumento ou usando a varivel de instncia $_name. + * + * @param string $name O nome para a sute de testes + * @return TestCollector Interface fluda + * @throws InvalidArgumentException + */ + public function createTestSuite($name = '') + { + if ((trim((string) $name)) == '' && $this->_name == '') { + throw new InvalidArgumentException('A classe concreta deve sobrescrever a ' + . 'varivel "$_name" ou passar um nome vlido ao chamar o mtodo' + . 'createTestSuite().'); + } + if (trim((string) $name) != '') { + $name = $this->_name; + } + + $this->_suite = new PHPUnit_Framework_TestSuite($name); + return $this; + } + + /** + * Adiciona os testes do diretrio da classe de definio de sute. + * + * @param PHPUnit_Framework_TestSuite $suite + * @return PHPUnit_Framework_TestSuite + */ + public function addDirectoryTests(PHPUnit_Framework_TestSuite $suite = NULL) + { + // Se no existir um objeto PHPUnit_Framework_TestSuite, cria um com o nome + // do arquivo da classe de definio da sute + if ($this->_suite == NULL && $suite == NULL) { + $this->createTestSuite(); + } + if ($suite == NULL) { + $suite = $this->_suite; + } + + $suite->addTestFiles($this->_collectTests()); + return $suite; + } + + /** + * Retorna um PHPUnit_Util_FilterIterator que contm as regras de incluso + * de testes do diretrio definido por $_fir. + * + * @return PHPUnit_Util_FilterIterator + */ + protected function _collectTests() + { + $testCollector = new PHPUnit_Runner_IncludePathTestCollector(array($this->_dir)); + return $testCollector->collectTests(); + } + + /** + * Define o diretrio atual da classe que estende TestCollector. O diretrio + * definido pela varivel de instncia $_file. + * + * @throws Exception Lana exceo + * @todo Refatorar o cdigo para utilizar {@link http://php.net/lsb Late static binding} + * quando a verso do PHP for a 5.3. + */ + protected function _defineCurrentDir() + { + if ($this->_file === NULL) { + throw new Exception('A classe concreta deve sobrescrever a varivel "$_file".'); + } + if ($this->_dir == '') { + $dir = realpath(dirname($this->_file)); + if (!is_dir($dir)) { + throw new Exception('The path "'. $dir .'" is not a valid directory'); + } + $this->_dir = $dir; + } + } +} \ No newline at end of file diff --git a/ieducar/tests/UnitBaseTest.class.php b/ieducar/tests/UnitBaseTest.class.php index c2f9977..ed000d2 100644 --- a/ieducar/tests/UnitBaseTest.class.php +++ b/ieducar/tests/UnitBaseTest.class.php @@ -1,6 +1,6 @@ + * @category i-Educar + * @license @@license@@ + * @package UnitTests + * @since Arquivo disponvel desde a verso 1.0.1 + * @version $Id$ */ - -/* - * Faz require do bootstrap para que as mesmas configuraes do ambiente - * (conexo com o banco de dados, ttulos, configuraes do PHP), sejam - * utilizadas pelos unit test para evitar discrepncias no comportamento. - */ -require_once realpath(dirname(__FILE__) . '/../') . '/includes/bootstrap.php'; - -chdir(realpath(dirname(__FILE__) . '/../') . '/intranet'); -require_once 'PHPUnit/Framework.php'; -require_once 'include/clsBanco.inc.php'; - - /** * UnitBaseTest abstract class. * - * Muda o diretrio atual para que os testes possam ser facilmente invocados - * em qualquer subdiretrio do sistema. - * * Abstrai o PHPUnit, diminuindo a dependncia de seu uso. * - * @author Eriksen Costa Paixo - * @license http://creativecommons.org/licenses/GPL/2.0/legalcode.pt CC GNU GPL - * @package Test - * @since Classe disponvel desde a verso 1.0.1 - * @version $Id$ + * @author Eriksen Costa Paixo + * @category i-Educar + * @license @@license@@ + * @package UnitTests + * @since Classe disponvel desde a verso 1.0.1 + * @version @@package_version@@ */ -abstract class UnitBaseTest extends PHPUnit_Framework_TestCase {} \ No newline at end of file +abstract class UnitBaseTest extends PHPUnit_Framework_TestCase +{ +} \ No newline at end of file diff --git a/ieducar/tests/bootstrap.php b/ieducar/tests/bootstrap.php new file mode 100644 index 0000000..1c00b3e --- /dev/null +++ b/ieducar/tests/bootstrap.php @@ -0,0 +1,60 @@ + + * + * Este programa software livre; voc pode redistribu-lo e/ou modific-lo + * sob os termos da Licena Pblica Geral GNU conforme publicada pela Free + * Software Foundation; tanto a verso 2 da Licena, como (a seu critrio) + * qualquer verso posterior. + * + * Este programa distribudo na expectativa de que seja til, porm, SEM + * NENHUMA GARANTIA; nem mesmo a garantia implcita de COMERCIABILIDADE OU + * ADEQUAO A UMA FINALIDADE ESPECFICA. Consulte a Licena Pblica Geral + * do GNU para mais detalhes. + * + * Voc deve ter recebido uma cpia da Licena Pblica Geral do GNU junto + * com este programa; se no, escreva para a Free Software Foundation, Inc., no + * endereo 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. + * + * @author Eriksen Costa Paixo + * @category i-Educar + * @license @@license@@ + * @package Tests + * @since Arquivo disponvel desde a verso 1.1.0 + * @version $Id$ + */ + +/** + * Arquivo de bootstrap para os testes do projeto. Configura o include_path e + * inclui alguns arquivos necessrios nos testes unitrios e funcionais. + */ + + +// Diretrio raiz do projeto. +$root = realpath(dirname(__FILE__) . '/../'); + +// Adiciona os diretrios tests/unit, tests/functional, tests/, ./ e intranet/ +// ao include_path. +$paths = array(); +$paths[] = join(DIRECTORY_SEPARATOR, array($root, 'tests', 'unit')); +$paths[] = join(DIRECTORY_SEPARATOR, array($root, 'tests', 'functional')); +$paths[] = join(DIRECTORY_SEPARATOR, array($root, 'tests')); +$paths[] = join(DIRECTORY_SEPARATOR, array($root, '.')); +$paths[] = join(DIRECTORY_SEPARATOR, array($root, 'intranet')); + +// Configura o include_path. +set_include_path(join(PATH_SEPARATOR, $paths) . PATH_SEPARATOR . get_include_path()); + +// Arquivos em intranet/ usam includes com caminho relativo, muda diretrio +// atual para evitar warnings e errors. +chdir($root . '/intranet'); +unset($root, $paths); + +require_once 'TestCollector.php'; +require_once 'UnitBaseTest.class.php'; +require_once 'FunctionalBaseTest.class.php'; +require_once 'include/clsBanco.inc.php'; \ No newline at end of file diff --git a/ieducar/tests/functional/AllTests.php b/ieducar/tests/functional/AllTests.php new file mode 100644 index 0000000..6ca6df7 --- /dev/null +++ b/ieducar/tests/functional/AllTests.php @@ -0,0 +1,53 @@ + + * + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) + * qualquer versão posterior. + * + * Este programa é distribuí­do na expectativa de que seja útil, porém, SEM + * NENHUMA GARANTIA; nem mesmo a garantia implí­cita de COMERCIABILIDADE OU + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral + * do GNU para mais detalhes. + * + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto + * com este programa; se não, escreva para a Free Software Foundation, Inc., no + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. + * + * @author Eriksen Costa Paixão + * @category i-Educar + * @license @@license@@ + * @package FunctionalTests + * @since Arquivo disponível desde a versão 1.1.0 + * @version $Id$ + */ + +/** + * Functionl_AllTests class. + * + * Arquivo de definição de suíte de testes funcionais. + * + * @author Eriksen Costa Paixão + * @category i-Educar + * @license @@license@@ + * @package FunctionalTests + * @since Classe disponível desde a versão 1.1.0 + * @version @@package_version@@ + */ +class Functional_AllTests extends TestCollector +{ + protected $_name = 'Suíte de testes funcionais do projeto'; + protected $_file = __FILE__; + + public static function suite() + { + $instance = new self; + return $instance->addDirectoryTests(); + } +} \ No newline at end of file diff --git a/ieducar/tests/functional/ServidorCategoriaNivelWebTest.class.php b/ieducar/tests/functional/ServidorCategoriaNivelWebTest.class.php deleted file mode 100644 index 86eaa19..0000000 --- a/ieducar/tests/functional/ServidorCategoriaNivelWebTest.class.php +++ /dev/null @@ -1,75 +0,0 @@ - - * - * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo - * sob os termos da Licença Pública Geral GNU conforme publicada pela Free - * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) - * qualquer versão posterior. - * - * Este programa é distribuí­do na expectativa de que seja útil, porém, SEM - * NENHUMA GARANTIA; nem mesmo a garantia implí­cita de COMERCIABILIDADE OU - * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral - * do GNU para mais detalhes. - * - * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto - * com este programa; se não, escreva para a Free Software Foundation, Inc., no - * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. - */ - -/** - * ServidorCategoriaNivelWebTest class. - * - * Testa as ações de atualizar um nível de categoria, como verificação - * da correção do bug #21. - * - * Esse teste precisa ser executado com o banco de dados distribuído na - * versão 1.0.0. - * - * @author Eriksen Costa Paixão - * @license http://creativecommons.org/licenses/GPL/2.0/legalcode.pt CC GNU GPL - * @package Test - * @subpackage FunctionalTest - * @since Classe disponível desde a versão 1.0.1 - * @version $Id$ - */ - -require_once realpath(dirname(__FILE__) . '/../') . '/FunctionalBaseTest.class.php'; - -class ServidorCategoriaNivelWebTest extends FunctionalBaseTest { - - private $slStringTest = 'Selenese Nivel Teste'; - - protected function tearDown() { - require_once 'include/pmieducar/clsPmieducarCategoriaNivel.inc.php'; - - $db = new clsBanco(); - $categoriaNivel = new clsPmieducarCategoriaNivel(); - $sql = sprintf('DELETE FROM %s WHERE %s = \'%s\'', - $categoriaNivel->_tabela, 'nm_categoria_nivel', $this->slStringTest); - - $db->Consulta($sql); - } - - private function createNewEntry() { - $this->open("/intranet/educar_categoria_nivel_lst.php"); - $this->clickAndWait("//input[@value=' Novo ']"); - $this->type("nm_categoria_nivel", $this->slStringTest); - $this->clickAndWait("btn_enviar"); - } - - public function testCategoriaNivelDelete() { - $this->doLogin(); - $this->createNewEntry(); - - $this->clickAndWait("link=" . $this->slStringTest); - $this->clickAndWait("//input[@value=' Editar ']"); - $this->clickAndWait("//input[@value=' Excluir ']"); - $this->assertTrue((bool) preg_match('/^Excluir registro[\s\S]$/', $this->getConfirmation())); - $this->assertTrue(!$this->isTextPresent($this->slStringTest)); - } -} \ No newline at end of file diff --git a/ieducar/tests/functional/ServidorCategoriaNivelWebTest.php b/ieducar/tests/functional/ServidorCategoriaNivelWebTest.php new file mode 100644 index 0000000..2b39088 --- /dev/null +++ b/ieducar/tests/functional/ServidorCategoriaNivelWebTest.php @@ -0,0 +1,83 @@ + + * + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) + * qualquer versão posterior. + * + * Este programa é distribuí­do na expectativa de que seja útil, porém, SEM + * NENHUMA GARANTIA; nem mesmo a garantia implí­cita de COMERCIABILIDADE OU + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral + * do GNU para mais detalhes. + * + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto + * com este programa; se não, escreva para a Free Software Foundation, Inc., no + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. + * + * @author Eriksen Costa Paixão + * @category i-Educar + * @license @@license@@ + * @package FunctionalTests + * @since Arquivo disponível desde a versão 1.0.1 + * @version $Id$ + */ + +require_once 'include/pmieducar/clsPmieducarCategoriaNivel.inc.php'; + +/** + * ServidorCategoriaNivelWebTest class. + * + * Testa as ações de atualizar um nível de categoria, como verificação + * da correção do bug #21. + * + * Esse teste precisa ser executado com o banco de dados distribuído na + * versão 1.0.0. + * + * @author Eriksen Costa Paixão + * @category i-Educar + * @license @@license@@ + * @link http://svn.softwarepublico.gov.br/trac/ieducar/ticket/21 + * @package FunctionalTests + * @since Classe disponível desde a versão 1.0.1 + * @version @@package_version@@ + */ +class ServidorCategoriaNivelWebTest extends FunctionalBaseTest +{ + private $slStringTest = 'Selenese Nivel Teste'; + + protected function tearDown() + { + $db = new clsBanco(); + $categoriaNivel = new clsPmieducarCategoriaNivel(); + $sql = sprintf('DELETE FROM %s WHERE %s = \'%s\'', + $categoriaNivel->_tabela, 'nm_categoria_nivel', $this->slStringTest); + + $db->Consulta($sql); + } + + private function createNewEntry() + { + $this->open("/intranet/educar_categoria_nivel_lst.php"); + $this->clickAndWait("//input[@value=' Novo ']"); + $this->type("nm_categoria_nivel", $this->slStringTest); + $this->clickAndWait("btn_enviar"); + } + + public function testCategoriaNivelDelete() + { + $this->doLogin(); + $this->createNewEntry(); + + $this->clickAndWait("link=" . $this->slStringTest); + $this->clickAndWait("//input[@value=' Editar ']"); + $this->clickAndWait("//input[@value=' Excluir ']"); + $this->assertTrue((bool) preg_match('/^Excluir registro[\s\S]$/', $this->getConfirmation())); + $this->assertTrue(!$this->isTextPresent($this->slStringTest)); + } +} \ No newline at end of file diff --git a/ieducar/tests/functional/ServidorMotivoAfastamentoWebTest.class.php b/ieducar/tests/functional/ServidorMotivoAfastamentoWebTest.class.php deleted file mode 100644 index b1e4ff1..0000000 --- a/ieducar/tests/functional/ServidorMotivoAfastamentoWebTest.class.php +++ /dev/null @@ -1,89 +0,0 @@ - - * - * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo - * sob os termos da Licença Pública Geral GNU conforme publicada pela Free - * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) - * qualquer versão posterior. - * - * Este programa é distribuí­do na expectativa de que seja útil, porém, SEM - * NENHUMA GARANTIA; nem mesmo a garantia implí­cita de COMERCIABILIDADE OU - * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral - * do GNU para mais detalhes. - * - * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto - * com este programa; se não, escreva para a Free Software Foundation, Inc., no - * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. - */ - -/** - * ServidorMotivoAfastamentoWebTest class. - * - * Testa as ações de atualizar e apagar um motivo de afastamento, como - * verificação da correção do bug #20. - * - * Esse teste precisa ser executado com o banco de dados distribuído na - * versão 1.0.0. - * - * @author Eriksen Costa Paixão - * @license http://creativecommons.org/licenses/GPL/2.0/legalcode.pt CC GNU GPL - * @package Test - * @since Classe disponível desde a versão 1.0.1 - * @version $Id$ - */ - -require_once realpath(dirname(__FILE__) . '/../') . '/FunctionalBaseTest.class.php'; - -class ServidorMotivoAfastamentoWebTest extends FunctionalBaseTest { - - /** - * Os testes a seguir cobrem o bug report #20. - * - * @link http://svn.softwarepublico.gov.br/trac/ieducar/ticket/20 Bug report #20 - * @{ - */ - public function createNewEntry() { - $this->open("/intranet/educar_motivo_afastamento_lst.php"); - $this->clickAndWait("//input[@value=' Novo ']"); - $this->select("ref_cod_instituicao", "label=i-Educar"); - $this->type("nm_motivo", "Motivo teste"); - $this->clickAndWait("btn_enviar"); - } - - public function testMotivoAfastamentoUpdate() { - $this->doLogin(); - $this->createNewEntry(); - - $this->open("/intranet/educar_motivo_afastamento_cad.php?cod_motivo_afastamento=1"); - $this->select("ref_cod_instituicao", "label=i-Educar"); - $this->type("nm_motivo", "Motivo teste"); - $this->clickAndWait("btn_enviar"); - - $statusMessage = $this->isTextPresent("Edição não realizada."); - $this->assertTrue(!$statusMessage); - $this->doLogout(); - } - - public function testMotivoAfastamentoDelete() { - $this->doLogin(); - - $this->open("/intranet/educar_motivo_afastamento_lst.php"); - $this->clickAndWait("link=Motivo teste"); - $this->clickAndWait("//input[@value=' Editar ']"); - $this->clickAndWait("//input[@value=' Excluir ']"); - $this->assertTrue((bool)preg_match('/^Excluir registro[\s\S]$/',$this->getConfirmation())); - $statusMessage = $this->isTextPresent("Exclusão não realizada."); - $this->assertTrue(!$statusMessage); - - $this->doLogout(); - } - /** - * }@ - */ - -} diff --git a/ieducar/tests/functional/ServidorMotivoAfastamentoWebTest.php b/ieducar/tests/functional/ServidorMotivoAfastamentoWebTest.php new file mode 100644 index 0000000..04b75dc --- /dev/null +++ b/ieducar/tests/functional/ServidorMotivoAfastamentoWebTest.php @@ -0,0 +1,88 @@ + + * + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) + * qualquer versão posterior. + * + * Este programa é distribuí­do na expectativa de que seja útil, porém, SEM + * NENHUMA GARANTIA; nem mesmo a garantia implí­cita de COMERCIABILIDADE OU + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral + * do GNU para mais detalhes. + * + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto + * com este programa; se não, escreva para a Free Software Foundation, Inc., no + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. + * + * @author Eriksen Costa Paixão + * @category i-Educar + * @license @@license@@ + * @package FunctionalTests + * @since Classe disponível desde a versão 1.0.1 + * @version $Id$ + */ + +/** + * ServidorMotivoAfastamentoWebTest class. + * + * Testa as ações de atualizar e apagar um motivo de afastamento, como + * verificação da correção do bug #20. + * + * Esse teste precisa ser executado com o banco de dados distribuído na + * versão 1.0.0. + * + * @author Eriksen Costa Paixão + * @category i-Educar + * @license @@license@@ + * @link http://svn.softwarepublico.gov.br/trac/ieducar/ticket/20 + * @package FunctionalTests + * @since Classe disponível desde a versão 1.0.1 + * @version @@package_version@@ + */ +class ServidorMotivoAfastamentoWebTest extends FunctionalBaseTest +{ + public function createNewEntry() + { + $this->open("/intranet/educar_motivo_afastamento_lst.php"); + $this->clickAndWait("//input[@value=' Novo ']"); + $this->select("ref_cod_instituicao", "label=i-Educar"); + $this->type("nm_motivo", "Motivo teste"); + $this->clickAndWait("btn_enviar"); + } + + public function testMotivoAfastamentoUpdate() + { + $this->doLogin(); + $this->createNewEntry(); + + $this->open("/intranet/educar_motivo_afastamento_cad.php?cod_motivo_afastamento=1"); + $this->select("ref_cod_instituicao", "label=i-Educar"); + $this->type("nm_motivo", "Motivo teste"); + $this->clickAndWait("btn_enviar"); + + $statusMessage = $this->isTextPresent("Edição não realizada."); + $this->assertTrue(!$statusMessage); + $this->doLogout(); + } + + public function testMotivoAfastamentoDelete() + { + $this->doLogin(); + + $this->open("/intranet/educar_motivo_afastamento_lst.php"); + $this->clickAndWait("link=Motivo teste"); + $this->clickAndWait("//input[@value=' Editar ']"); + $this->clickAndWait("//input[@value=' Excluir ']"); + $this->assertTrue((bool)preg_match('/^Excluir registro[\s\S]$/',$this->getConfirmation())); + $statusMessage = $this->isTextPresent("Exclusão não realizada."); + $this->assertTrue(!$statusMessage); + + $this->doLogout(); + } +} \ No newline at end of file diff --git a/ieducar/tests/unit/AllTests.php b/ieducar/tests/unit/AllTests.php new file mode 100644 index 0000000..af6390f --- /dev/null +++ b/ieducar/tests/unit/AllTests.php @@ -0,0 +1,59 @@ + + * + * Este programa software livre; voc pode redistribu-lo e/ou modific-lo + * sob os termos da Licena Pblica Geral GNU conforme publicada pela Free + * Software Foundation; tanto a verso 2 da Licena, como (a seu critrio) + * qualquer verso posterior. + * + * Este programa distribudo na expectativa de que seja til, porm, SEM + * NENHUMA GARANTIA; nem mesmo a garantia implcita de COMERCIABILIDADE OU + * ADEQUAO A UMA FINALIDADE ESPECFICA. Consulte a Licena Pblica Geral + * do GNU para mais detalhes. + * + * Voc deve ter recebido uma cpia da Licena Pblica Geral do GNU junto + * com este programa; se no, escreva para a Free Software Foundation, Inc., no + * endereo 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. + * + * @author Eriksen Costa Paixo + * @category i-Educar + * @license @@license@@ + * @package UnitTests + * @since Arquivo disponvel desde a verso 1.1.0 + * @version $Id$ + */ + +require_once 'App/AllTests.php'; +require_once 'Core/AllTests.php'; +require_once 'CoreExt/AllTests.php'; +require_once 'Utils/AllTests.php'; + +/** + * Unit_AllTests class. + * + * Arquivo de definio de sute de testes unitrios. + * + * @author Eriksen Costa Paixo + * @category i-Educar + * @license @@license@@ + * @package UnitTests + * @since Classe disponvel desde a verso 1.1.0 + * @version @@package_version@@ + */ +class Unit_AllTests +{ + public static function suite() + { + $suite = new PHPUnit_Framework_TestSuite('Sute de testes unitrios do projeto'); + $suite->addTest(App_AllTests::suite()); + $suite->addTest(Core_AllTests::suite()); + $suite->addTest(CoreExt_AllTests::suite()); + $suite->addTest(Utils_AllTests::suite()); + return $suite; + } +} \ No newline at end of file diff --git a/ieducar/tests/unit/App/AllTests.php b/ieducar/tests/unit/App/AllTests.php new file mode 100644 index 0000000..1fd7536 --- /dev/null +++ b/ieducar/tests/unit/App/AllTests.php @@ -0,0 +1,57 @@ + + * + * Este programa software livre; voc pode redistribu-lo e/ou modific-lo + * sob os termos da Licena Pblica Geral GNU conforme publicada pela Free + * Software Foundation; tanto a verso 2 da Licena, como (a seu critrio) + * qualquer verso posterior. + * + * Este programa distribudo na expectativa de que seja til, porm, SEM + * NENHUMA GARANTIA; nem mesmo a garantia implcita de COMERCIABILIDADE OU + * ADEQUAO A UMA FINALIDADE ESPECFICA. Consulte a Licena Pblica Geral + * do GNU para mais detalhes. + * + * Voc deve ter recebido uma cpia da Licena Pblica Geral do GNU junto + * com este programa; se no, escreva para a Free Software Foundation, Inc., no + * endereo 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. + * + * @author Eriksen Costa Paixo + * @category i-Educar + * @license @@license@@ + * @package App + * @subpackage UnitTests + * @since Arquivo disponvel desde a verso 1.1.0 + * @version $Id$ + */ + +require_once 'App/Model/AllTests.php'; +require_once 'App/Service/AllTests.php'; + +/** + * App_AllTests class. + * + * Arquivo de definio de sute para o pacote App. + * + * @author Eriksen Costa Paixo + * @category i-Educar + * @license @@license@@ + * @package App + * @subpackage UnitTests + * @since Classe disponvel desde a verso 1.1.0 + * @version @@package_version@@ + */ +class App_AllTests +{ + public static function suite() + { + $suite = new PHPUnit_Framework_TestSuite('Sute de testes unitrios de App'); + $suite->addTest(App_Model_AllTests::suite()); + $suite->addTest(App_Service_AllTests::suite()); + return $suite; + } +} \ No newline at end of file diff --git a/ieducar/tests/unit/App/Model/AllTests.php b/ieducar/tests/unit/App/Model/AllTests.php new file mode 100644 index 0000000..855e287 --- /dev/null +++ b/ieducar/tests/unit/App/Model/AllTests.php @@ -0,0 +1,55 @@ + + * + * Este programa software livre; voc pode redistribu-lo e/ou modific-lo + * sob os termos da Licena Pblica Geral GNU conforme publicada pela Free + * Software Foundation; tanto a verso 2 da Licena, como (a seu critrio) + * qualquer verso posterior. + * + * Este programa distribudo na expectativa de que seja til, porm, SEM + * NENHUMA GARANTIA; nem mesmo a garantia implcita de COMERCIABILIDADE OU + * ADEQUAO A UMA FINALIDADE ESPECFICA. Consulte a Licena Pblica Geral + * do GNU para mais detalhes. + * + * Voc deve ter recebido uma cpia da Licena Pblica Geral do GNU junto + * com este programa; se no, escreva para a Free Software Foundation, Inc., no + * endereo 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. + * + * @author Eriksen Costa Paixo + * @category i-Educar + * @license @@license@@ + * @package App_Model + * @subpackage UnitTests + * @since Arquivo disponvel desde a verso 1.1.0 + * @version $Id$ + */ + +/** + * App_Model_AllTests class. + * + * Arquivo de definio de sute para o pacote App_Model. + * + * @author Eriksen Costa Paixo + * @category i-Educar + * @license @@license@@ + * @package App_Model + * @subpackage UnitTests + * @since Classe disponvel desde a verso 1.1.0 + * @version @@package_version@@ + */ +class App_Model_AllTests extends TestCollector +{ + protected $_name = 'Sute de testes unitrios de App_Model'; + protected $_file = __FILE__; + + public static function suite() + { + $instance = new self(); + return $instance->addDirectoryTests(); + } +} \ No newline at end of file diff --git a/ieducar/tests/unit/App/Service/AllTests.php b/ieducar/tests/unit/App/Service/AllTests.php new file mode 100644 index 0000000..246f161 --- /dev/null +++ b/ieducar/tests/unit/App/Service/AllTests.php @@ -0,0 +1,55 @@ + + * + * Este programa software livre; voc pode redistribu-lo e/ou modific-lo + * sob os termos da Licena Pblica Geral GNU conforme publicada pela Free + * Software Foundation; tanto a verso 2 da Licena, como (a seu critrio) + * qualquer verso posterior. + * + * Este programa distribudo na expectativa de que seja til, porm, SEM + * NENHUMA GARANTIA; nem mesmo a garantia implcita de COMERCIABILIDADE OU + * ADEQUAO A UMA FINALIDADE ESPECFICA. Consulte a Licena Pblica Geral + * do GNU para mais detalhes. + * + * Voc deve ter recebido uma cpia da Licena Pblica Geral do GNU junto + * com este programa; se no, escreva para a Free Software Foundation, Inc., no + * endereo 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. + * + * @author Eriksen Costa Paixo + * @category i-Educar + * @license @@license@@ + * @package App_Service + * @subpackage UnitTests + * @since Arquivo disponvel desde a verso 1.1.0 + * @version $Id$ + */ + +/** + * App_Service_AllTests class. + * + * Arquivo de definio de sute para o pacote App_Service. + * + * @author Eriksen Costa Paixo + * @category i-Educar + * @license @@license@@ + * @package App_Service + * @subpackage UnitTests + * @since Classe disponvel desde a verso 1.1.0 + * @version @@package_version@@ + */ +class App_Service_AllTests extends TestCollector +{ + protected $_name = 'Sute de testes unitrios de App_Service'; + protected $_file = __FILE__; + + public static function suite() + { + $instance = new self(); + return $instance->addDirectoryTests(); + } +} \ No newline at end of file diff --git a/ieducar/tests/unit/ClsBancoTest.class.php b/ieducar/tests/unit/ClsBancoTest.class.php deleted file mode 100644 index 3b9f607..0000000 --- a/ieducar/tests/unit/ClsBancoTest.class.php +++ /dev/null @@ -1,65 +0,0 @@ - - * - * Este programa software livre; voc pode redistribu-lo e/ou modific-lo - * sob os termos da Licena Pblica Geral GNU conforme publicada pela Free - * Software Foundation; tanto a verso 2 da Licena, como (a seu critrio) - * qualquer verso posterior. - * - * Este programa distribudo na expectativa de que seja til, porm, SEM - * NENHUMA GARANTIA; nem mesmo a garantia implcita de COMERCIABILIDADE OU - * ADEQUAO A UMA FINALIDADE ESPECFICA. Consulte a Licena Pblica Geral - * do GNU para mais detalhes. - * - * Voc deve ter recebido uma cpia da Licena Pblica Geral do GNU junto - * com este programa; se no, escreva para a Free Software Foundation, Inc., no - * endereo 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. - * - * @author Eriksen Costa Paixo - * @license http://creativecommons.org/licenses/GPL/2.0/legalcode.pt CC GNU GPL - * @package Test - * @subpackage UnitTest - * @since Arquivo disponvel desde a verso 1.0.1 - * @version $Id$ - */ - -require_once realpath(dirname(__FILE__) . '/../') . '/UnitBaseTest.class.php'; -require_once 'include/pmieducar/clsPmieducarClienteSuspensao.inc.php'; - - -/** - * clsBancoTest class. - * - * @author Eriksen Costa Paixo - * @license http://creativecommons.org/licenses/GPL/2.0/legalcode.pt CC GNU GPL - * @package Test - * @subpackage UnitTest - * @since Classe disponvel desde a verso 1.0.1 - * @version $Id$ - */ -class ClsBancoTest extends UnitBaseTest -{ - - public function testDoCountFromObj() - { - $db = new clsBanco(); - $db->Conecta(); - - $obj = new clsPmieducarClienteSuspensao(); - $this->assertNotEquals(TRUE, is_null($db->doCountFromObj($obj))); - } - - public function testConexao() - { - $db = new clsBanco(); - $db->Conecta(); - - $this->assertTrue((bool) $db->bLink_ID); - } - -} diff --git a/ieducar/tests/unit/ClsConfigItajaiTest.class.php b/ieducar/tests/unit/ClsConfigItajaiTest.class.php deleted file mode 100644 index a9778d2..0000000 --- a/ieducar/tests/unit/ClsConfigItajaiTest.class.php +++ /dev/null @@ -1,75 +0,0 @@ - - * - * Este programa software livre; voc pode redistribu-lo e/ou modific-lo - * sob os termos da Licena Pblica Geral GNU conforme publicada pela Free - * Software Foundation; tanto a verso 2 da Licena, como (a seu critrio) - * qualquer verso posterior. - * - * Este programa distribudo na expectativa de que seja til, porm, SEM - * NENHUMA GARANTIA; nem mesmo a garantia implcita de COMERCIABILIDADE OU - * ADEQUAO A UMA FINALIDADE ESPECFICA. Consulte a Licena Pblica Geral - * do GNU para mais detalhes. - * - * Voc deve ter recebido uma cpia da Licena Pblica Geral do GNU junto - * com este programa; se no, escreva para a Free Software Foundation, Inc., no - * endereo 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. - */ - -require_once realpath(dirname(__FILE__) . '/../') . '/UnitBaseTest.class.php'; -require_once 'clsConfigItajai.inc.php'; - - -/** - * clsConfigItajaiTest class. - * - * @author Eriksen Costa Paixo - * @license http://creativecommons.org/licenses/GPL/2.0/legalcode.pt CC GNU GPL - * @package Test - * @subpackage UnitTest - * @since Classe disponvel desde a verso 1.1.0 - * @version $Id$ - */ -class ClsConfigItajai extends UnitBaseTest -{ - - /** - * @var clsConfig - */ - protected $config = NULL; - - protected function setUp() { - $this->config = new clsConfig(); - } - - public function testConfigInstituicao() { - $this->assertEquals('i-Educar - ', $this->config->_instituicao); - } - - public function testArrayConfigHasEmailsAdministradores() { - $this->assertTrue((bool) count($this->config->arrayConfig['ArrStrEmailsAdministradores'])); - } - - public function testArrayCheckEmailAdministradores() { - $this->assertEquals('seu.email@example.com', - $this->config->arrayConfig['ArrStrEmailsAdministradores'][0]); - } - - public function testArrayConfigDirectoryTemplates() { - $this->assertEquals('templates/', $this->config->arrayConfig['strDirTemplates']); - } - - public function testArrayConfigIntSegundosQuerySql() { - $this->assertEquals(3, $this->config->arrayConfig['intSegundosQuerySQL']); - } - - public function testArrayConfigIntSegundosPagina() { - $this->assertEquals(5, $this->config->arrayConfig['intSegundosProcessaPagina']); - } - -} \ No newline at end of file diff --git a/ieducar/tests/unit/ClsPmieducarQuadroHorarioHorariosTest.class.php b/ieducar/tests/unit/ClsPmieducarQuadroHorarioHorariosTest.class.php deleted file mode 100644 index 7c4a42d..0000000 --- a/ieducar/tests/unit/ClsPmieducarQuadroHorarioHorariosTest.class.php +++ /dev/null @@ -1,52 +0,0 @@ - - * - * Este programa software livre; voc pode redistribu-lo e/ou modific-lo - * sob os termos da Licena Pblica Geral GNU conforme publicada pela Free - * Software Foundation; tanto a verso 2 da Licena, como (a seu critrio) - * qualquer verso posterior. - * - * Este programa distribudo na expectativa de que seja til, porm, SEM - * NENHUMA GARANTIA; nem mesmo a garantia implcita de COMERCIABILIDADE OU - * ADEQUAO A UMA FINALIDADE ESPECFICA. Consulte a Licena Pblica Geral - * do GNU para mais detalhes. - * - * Voc deve ter recebido uma cpia da Licena Pblica Geral do GNU junto - * com este programa; se no, escreva para a Free Software Foundation, Inc., no - * endereo 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. - */ - -/** - * ClsPmieducarQuadroHorarioHorariosTest class - * - * @author Eriksen Costa Paixo - * @license http://creativecommons.org/licenses/GPL/2.0/legalcode.pt CC GNU GPL - * @package Test - * @since Classe disponvel desde a verso 1.0.2 - * @version $Id$ - */ - -require_once realpath(dirname(__FILE__) . '/../') . '/UnitBaseTest.class.php'; -require_once 'include/pmieducar/clsPmieducarQuadroHorarioHorarios.inc.php'; - -class ClsPmieducarQuadroHorarioHorariosTest extends UnitBaseTest { - - /** - * Testa o mtodo substituir_servidor() - */ - public function testSubstituirServidor() { - $stub = $this->getMock('clsPmieducarQuadroHorarioHorarios'); - - $stub->expects($this->any()) - ->method('substituir_servidor') - ->will($this->returnValue(TRUE)); - - $this->assertTrue($stub->substituir_servidor(1)); - } - -} \ No newline at end of file diff --git a/ieducar/tests/unit/ClsPmieducarServidorAlocacaoTest.class.php b/ieducar/tests/unit/ClsPmieducarServidorAlocacaoTest.class.php deleted file mode 100644 index fc1b214..0000000 --- a/ieducar/tests/unit/ClsPmieducarServidorAlocacaoTest.class.php +++ /dev/null @@ -1,52 +0,0 @@ - - * - * Este programa software livre; voc pode redistribu-lo e/ou modific-lo - * sob os termos da Licena Pblica Geral GNU conforme publicada pela Free - * Software Foundation; tanto a verso 2 da Licena, como (a seu critrio) - * qualquer verso posterior. - * - * Este programa distribudo na expectativa de que seja til, porm, SEM - * NENHUMA GARANTIA; nem mesmo a garantia implcita de COMERCIABILIDADE OU - * ADEQUAO A UMA FINALIDADE ESPECFICA. Consulte a Licena Pblica Geral - * do GNU para mais detalhes. - * - * Voc deve ter recebido uma cpia da Licena Pblica Geral do GNU junto - * com este programa; se no, escreva para a Free Software Foundation, Inc., no - * endereo 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. - */ - -/** - * ClsPmieducarServidorAlocacaoTest class - * - * @author Eriksen Costa Paixo - * @license http://creativecommons.org/licenses/GPL/2.0/legalcode.pt CC GNU GPL - * @package Test - * @since Classe disponvel desde a verso 1.0.2 - * @version $Id$ - */ - -require_once realpath(dirname(__FILE__) . '/../') . '/UnitBaseTest.class.php'; -require_once 'include/pmieducar/clsPmieducarServidorAlocacao.inc.php'; - -class ClsPmieducarServidorAlocacaoTest extends UnitBaseTest { - - /** - * Testa o mtodo substituir_servidor() - */ - public function testSubstituirServidor() { - $stub = $this->getMock('clsPmieducarServidorAlocacao'); - - $stub->expects($this->any()) - ->method('substituir_servidor') - ->will($this->returnValue(TRUE)); - - $this->assertTrue($stub->substituir_servidor(1)); - } - -} \ No newline at end of file diff --git a/ieducar/tests/unit/Core/AllTests.php b/ieducar/tests/unit/Core/AllTests.php new file mode 100644 index 0000000..b4b7444 --- /dev/null +++ b/ieducar/tests/unit/Core/AllTests.php @@ -0,0 +1,57 @@ + + * + * Este programa software livre; voc pode redistribu-lo e/ou modific-lo + * sob os termos da Licena Pblica Geral GNU conforme publicada pela Free + * Software Foundation; tanto a verso 2 da Licena, como (a seu critrio) + * qualquer verso posterior. + * + * Este programa distribudo na expectativa de que seja til, porm, SEM + * NENHUMA GARANTIA; nem mesmo a garantia implcita de COMERCIABILIDADE OU + * ADEQUAO A UMA FINALIDADE ESPECFICA. Consulte a Licena Pblica Geral + * do GNU para mais detalhes. + * + * Voc deve ter recebido uma cpia da Licena Pblica Geral do GNU junto + * com este programa; se no, escreva para a Free Software Foundation, Inc., no + * endereo 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. + * + * @author Eriksen Costa Paixo + * @category i-Educar + * @license @@license@@ + * @package Core + * @subpackage UnitTests + * @since Arquivo disponvel desde a verso 1.1.0 + * @version $Id$ + */ + +require_once 'App/Model/AllTests.php'; + +/** + * Core_AllTests class. + * + * Arquivo de definio de sute para o pacote Core (objetos legados). + * + * @author Eriksen Costa Paixo + * @category i-Educar + * @license @@license@@ + * @package Core + * @subpackage UnitTests + * @since Classe disponvel desde a verso 1.1.0 + * @version @@package_version@@ + */ +class Core_AllTests extends TestCollector +{ + protected $_name = 'Sute de testes unitrios de Core (objetos legados)'; + protected $_file = __FILE__; + + public static function suite() + { + $instance = new self; + return $instance->addDirectoryTests(); + } +} \ No newline at end of file diff --git a/ieducar/tests/unit/Core/ClsBancoTest.php b/ieducar/tests/unit/Core/ClsBancoTest.php new file mode 100644 index 0000000..19da20b --- /dev/null +++ b/ieducar/tests/unit/Core/ClsBancoTest.php @@ -0,0 +1,64 @@ + + * + * Este programa software livre; voc pode redistribu-lo e/ou modific-lo + * sob os termos da Licena Pblica Geral GNU conforme publicada pela Free + * Software Foundation; tanto a verso 2 da Licena, como (a seu critrio) + * qualquer verso posterior. + * + * Este programa distribudo na expectativa de que seja til, porm, SEM + * NENHUMA GARANTIA; nem mesmo a garantia implcita de COMERCIABILIDADE OU + * ADEQUAO A UMA FINALIDADE ESPECFICA. Consulte a Licena Pblica Geral + * do GNU para mais detalhes. + * + * Voc deve ter recebido uma cpia da Licena Pblica Geral do GNU junto + * com este programa; se no, escreva para a Free Software Foundation, Inc., no + * endereo 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. + * + * @author Eriksen Costa Paixo + * @category i-Educar + * @license @@license@@ + * @package Core + * @subpackage UnitTests + * @since Arquivo disponvel desde a verso 1.0.1 + * @version $Id$ + */ + +require_once 'include/pmieducar/clsPmieducarClienteSuspensao.inc.php'; + +/** + * clsBancoTest class. + * + * @author Eriksen Costa Paixo + * @category i-Educar + * @license @@license@@ + * @package Core + * @subpackage UnitTests + * @since Classe disponvel desde a verso 1.0.1 + * @todo Mover mtodo testConexao() para o pacote FunctionalTests + * @version @@package_version@@ + */ +class ClsBancoTest extends UnitBaseTest +{ + public function testDoCountFromObj() + { + $db = new clsBanco(); + $db->Conecta(); + + $obj = new clsPmieducarClienteSuspensao(); + $this->assertNotEquals(TRUE, is_null($db->doCountFromObj($obj))); + } + + public function testConexao() + { + $db = new clsBanco(); + $db->Conecta(); + + $this->assertTrue((bool) $db->bLink_ID); + } +} \ No newline at end of file diff --git a/ieducar/tests/unit/Core/ClsConfigItajaiTest.php b/ieducar/tests/unit/Core/ClsConfigItajaiTest.php new file mode 100644 index 0000000..fa6c617 --- /dev/null +++ b/ieducar/tests/unit/Core/ClsConfigItajaiTest.php @@ -0,0 +1,85 @@ + + * + * Este programa software livre; voc pode redistribu-lo e/ou modific-lo + * sob os termos da Licena Pblica Geral GNU conforme publicada pela Free + * Software Foundation; tanto a verso 2 da Licena, como (a seu critrio) + * qualquer verso posterior. + * + * Este programa distribudo na expectativa de que seja til, porm, SEM + * NENHUMA GARANTIA; nem mesmo a garantia implcita de COMERCIABILIDADE OU + * ADEQUAO A UMA FINALIDADE ESPECFICA. Consulte a Licena Pblica Geral + * do GNU para mais detalhes. + * + * Voc deve ter recebido uma cpia da Licena Pblica Geral do GNU junto + * com este programa; se no, escreva para a Free Software Foundation, Inc., no + * endereo 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. + * + * @author Eriksen Costa Paixo + * @category i-Educar + * @license @@license@@ + * @package Core + * @subpackage UnitTests + * @since Arquivo disponvel desde a verso 1.1.0 + * @version $Id$ + */ + +require_once 'clsConfigItajai.inc.php'; + + +/** + * clsConfigItajaiTest class. + * + * @author Eriksen Costa Paixo + * @category i-Educar + * @license @@license@@ + * @package Core + * @subpackage UnitTests + * @since Classe disponvel desde a verso 1.0.1 + * @version @@package_version@@ + */ +class ClsConfigItajai extends UnitBaseTest +{ + protected $config = NULL; + + protected function setUp() + { + $this->config = new clsConfig(); + } + + public function testConfigInstituicao() + { + $this->assertEquals('i-Educar - ', $this->config->_instituicao); + } + + public function testArrayConfigHasEmailsAdministradores() + { + $this->assertTrue((bool) count($this->config->arrayConfig['ArrStrEmailsAdministradores'])); + } + + public function testArrayCheckEmailAdministradores() + { + $this->assertEquals('seu.email@example.com', + $this->config->arrayConfig['ArrStrEmailsAdministradores'][0]); + } + + public function testArrayConfigDirectoryTemplates() + { + $this->assertEquals('templates/', $this->config->arrayConfig['strDirTemplates']); + } + + public function testArrayConfigIntSegundosQuerySql() + { + $this->assertEquals(3, $this->config->arrayConfig['intSegundosQuerySQL']); + } + + public function testArrayConfigIntSegundosPagina() + { + $this->assertEquals(5, $this->config->arrayConfig['intSegundosProcessaPagina']); + } +} \ No newline at end of file diff --git a/ieducar/tests/unit/Core/ClsPmieducarQuadroHorarioHorariosTest.php b/ieducar/tests/unit/Core/ClsPmieducarQuadroHorarioHorariosTest.php new file mode 100644 index 0000000..d51059c --- /dev/null +++ b/ieducar/tests/unit/Core/ClsPmieducarQuadroHorarioHorariosTest.php @@ -0,0 +1,60 @@ + + * + * Este programa software livre; voc pode redistribu-lo e/ou modific-lo + * sob os termos da Licena Pblica Geral GNU conforme publicada pela Free + * Software Foundation; tanto a verso 2 da Licena, como (a seu critrio) + * qualquer verso posterior. + * + * Este programa distribudo na expectativa de que seja til, porm, SEM + * NENHUMA GARANTIA; nem mesmo a garantia implcita de COMERCIABILIDADE OU + * ADEQUAO A UMA FINALIDADE ESPECFICA. Consulte a Licena Pblica Geral + * do GNU para mais detalhes. + * + * Voc deve ter recebido uma cpia da Licena Pblica Geral do GNU junto + * com este programa; se no, escreva para a Free Software Foundation, Inc., no + * endereo 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. + * + * @author Eriksen Costa Paixo + * @category i-Educar + * @license @@license@@ + * @package Core + * @subpackage UnitTests + * @since Arquivo disponvel desde a verso 1.0.2 + * @version $Id$ + */ + +require_once 'include/pmieducar/clsPmieducarQuadroHorarioHorarios.inc.php'; + +/** + * ClsPmieducarQuadroHorarioHorariosTest class. + * + * @author Eriksen Costa Paixo + * @category i-Educar + * @license @@license@@ + * @package Core + * @subpackage UnitTests + * @since Classe disponvel desde a verso 1.0.2 + * @version @@package_version@@ + */ +class ClsPmieducarQuadroHorarioHorariosTest extends UnitBaseTest +{ + /** + * Testa o mtodo substituir_servidor() + */ + public function testSubstituirServidor() + { + $stub = $this->getMock('clsPmieducarQuadroHorarioHorarios'); + + $stub->expects($this->any()) + ->method('substituir_servidor') + ->will($this->returnValue(TRUE)); + + $this->assertTrue($stub->substituir_servidor(1)); + } +} \ No newline at end of file diff --git a/ieducar/tests/unit/Core/ClsPmieducarServidorAlocacaoTest.php b/ieducar/tests/unit/Core/ClsPmieducarServidorAlocacaoTest.php new file mode 100644 index 0000000..24db2ce --- /dev/null +++ b/ieducar/tests/unit/Core/ClsPmieducarServidorAlocacaoTest.php @@ -0,0 +1,60 @@ + + * + * Este programa software livre; voc pode redistribu-lo e/ou modific-lo + * sob os termos da Licena Pblica Geral GNU conforme publicada pela Free + * Software Foundation; tanto a verso 2 da Licena, como (a seu critrio) + * qualquer verso posterior. + * + * Este programa distribudo na expectativa de que seja til, porm, SEM + * NENHUMA GARANTIA; nem mesmo a garantia implcita de COMERCIABILIDADE OU + * ADEQUAO A UMA FINALIDADE ESPECFICA. Consulte a Licena Pblica Geral + * do GNU para mais detalhes. + * + * Voc deve ter recebido uma cpia da Licena Pblica Geral do GNU junto + * com este programa; se no, escreva para a Free Software Foundation, Inc., no + * endereo 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. + * + * @author Eriksen Costa Paixo + * @category i-Educar + * @license @@license@@ + * @package Core + * @subpackage UnitTests + * @since Arquivo disponvel desde a verso 1.0.2 + * @version $Id$ + */ + +require_once 'include/pmieducar/clsPmieducarServidorAlocacao.inc.php'; + +/** + * ClsPmieducarServidorAlocacaoTest class. + * + * @author Eriksen Costa Paixo + * @category i-Educar + * @license @@license@@ + * @package Core + * @subpackage UnitTests + * @since Classe disponvel desde a verso 1.0.2 + * @version @@package_version@@ + */ +class ClsPmieducarServidorAlocacaoTest extends UnitBaseTest +{ + /** + * Testa o mtodo substituir_servidor(). + */ + public function testSubstituirServidor() + { + $stub = $this->getMock('clsPmieducarServidorAlocacao'); + + $stub->expects($this->any()) + ->method('substituir_servidor') + ->will($this->returnValue(TRUE)); + + $this->assertTrue($stub->substituir_servidor(1)); + } +} \ No newline at end of file diff --git a/ieducar/tests/unit/CoreExt/AllTests.php b/ieducar/tests/unit/CoreExt/AllTests.php new file mode 100644 index 0000000..33b68a9 --- /dev/null +++ b/ieducar/tests/unit/CoreExt/AllTests.php @@ -0,0 +1,55 @@ + + * + * Este programa software livre; voc pode redistribu-lo e/ou modific-lo + * sob os termos da Licena Pblica Geral GNU conforme publicada pela Free + * Software Foundation; tanto a verso 2 da Licena, como (a seu critrio) + * qualquer verso posterior. + * + * Este programa distribudo na expectativa de que seja til, porm, SEM + * NENHUMA GARANTIA; nem mesmo a garantia implcita de COMERCIABILIDADE OU + * ADEQUAO A UMA FINALIDADE ESPECFICA. Consulte a Licena Pblica Geral + * do GNU para mais detalhes. + * + * Voc deve ter recebido uma cpia da Licena Pblica Geral do GNU junto + * com este programa; se no, escreva para a Free Software Foundation, Inc., no + * endereo 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. + * + * @author Eriksen Costa Paixo + * @category i-Educar + * @license @@license@@ + * @package CoreExt + * @subpackage UnitTests + * @since Arquivo disponvel desde a verso 1.1.0 + * @version $Id$ + */ + +/** + * CoreExt_AllTests class. + * + * Arquivo de definio de sute para o pacote CoreExt (nova API). + * + * @author Eriksen Costa Paixo + * @category i-Educar + * @license @@license@@ + * @package CoreExt + * @subpackage UnitTests + * @since Classe disponvel desde a verso 1.1.0 + * @version @@package_version@@ + */ +class CoreExt_AllTests extends TestCollector +{ + protected $_name = 'Sute de testes unitrios de CoreExt'; + protected $_file = __FILE__; + + public static function suite() + { + $instance = new self; + return $instance->addDirectoryTests(); + } +} \ No newline at end of file diff --git a/ieducar/tests/unit/CoreExt/CoreExt_ConfigTest.php b/ieducar/tests/unit/CoreExt/CoreExt_ConfigTest.php new file mode 100644 index 0000000..7b19f46 --- /dev/null +++ b/ieducar/tests/unit/CoreExt/CoreExt_ConfigTest.php @@ -0,0 +1,145 @@ + + * + * Este programa software livre; voc pode redistribu-lo e/ou modific-lo + * sob os termos da Licena Pblica Geral GNU conforme publicada pela Free + * Software Foundation; tanto a verso 2 da Licena, como (a seu critrio) + * qualquer verso posterior. + * + * Este programa distribudo na expectativa de que seja til, porm, SEM + * NENHUMA GARANTIA; nem mesmo a garantia implcita de COMERCIABILIDADE OU + * ADEQUAO A UMA FINALIDADE ESPECFICA. Consulte a Licena Pblica Geral + * do GNU para mais detalhes. + * + * Voc deve ter recebido uma cpia da Licena Pblica Geral do GNU junto + * com este programa; se no, escreva para a Free Software Foundation, Inc., no + * endereo 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. + * + * @author Eriksen Costa Paixo + * @category i-Educar + * @license @@license@@ + * @package CoreExt + * @subpackage UnitTests + * @since Arquivo disponvel desde a verso 1.1.0 + * @version $Id$ + */ + +require_once 'CoreExt/Config.class.php'; + +/** + * CoreExt_ConfigTest class. + * + * @author Eriksen Costa Paixo + * @category i-Educar + * @license @@license@@ + * @package CoreExt + * @subpackage UnitTests + * @since Classe disponvel desde a verso 1.1.0 + * @version @@package_version@@ + */ +class CoreExt_ConfigTest extends UnitBaseTest +{ + public function testConfigHasValueFromArray() + { + $arr = array( + 'app' => array( + 'database' => array( + 'dbname' => 'ieducardb', + 'username' => 'ieducaruser', + 'password' => '12345678' + ) + ), + 'version' => 'Development' + ); + + $config = new CoreExt_Config($arr); + $this->assertEquals('ieducardb', $config->app->database->dbname); + $this->assertEquals('Development', $config->version); + } + + public function testHasOneItem() + { + $arr = array( + 'app' => array('database' => '') + ); + + $config = new CoreExt_Config($arr); + $this->assertEquals(1, $config->count()); + } + + public function testHasTwoItems() + { + $arr = array( + 'app' => array('database' => '', 'template' => ''), + 'php' => '' + ); + + $config = new CoreExt_Config($arr); + $this->assertEquals(2, $config->count()); + $this->assertEquals(2, $config->app->count()); + } + + /** + * @expectedException Exception + */ + public function testGetNotExistNotProvidingDefaultValue() + { + $arr = array('app' => array('database' => array('dbname' => 'ieducardb'))); + + $config = new CoreExt_Config($arr); + $hostname = $config->get($config->app->database->hostname); + $this->assertEquals($hostname, '127.0.0.1'); + } + + public function testGetNotExistProvidingDefaultValue() + { + $arr = array('app' => array('database' => array('dbname' => 'ieducardb'))); + + $config = new CoreExt_Config($arr); + $hostname = $config->get($config->app->database->hostname, '127.0.0.1'); + $this->assertEquals($hostname, '127.0.0.1'); + } + + public function testGetExistProvidingDefaultValue() + { + $arr = array('app' => array('database' => array('dbname' => 'ieducardb'))); + + $config = new CoreExt_Config($arr); + $hostname = $config->get($config->app->database->dbname, '127.0.0.1'); + $this->assertEquals($hostname, 'ieducardb'); + } + + public function testObjectIterates() + { + $arr = array( + 'index1' => 1, + 'index2' => 2 + ); + + $config = new CoreExt_Config($arr); + + $this->assertEquals(1, $config->current()); + + $config->next(); + $this->assertEquals(2, $config->current()); + + foreach ($config as $key => $val) {} + + $config->rewind(); + $this->assertEquals(1, $config->current()); + } + + public function testTransformObjectInArray() + { + $arr = array(6, 3, 3); + + $config = new CoreExt_Config($arr); + + $this->assertEquals($arr, $config->toArray()); + } +} \ No newline at end of file diff --git a/ieducar/tests/unit/CoreExt/CoreExt_Config_IniTest.php b/ieducar/tests/unit/CoreExt/CoreExt_Config_IniTest.php new file mode 100644 index 0000000..3af0827 --- /dev/null +++ b/ieducar/tests/unit/CoreExt/CoreExt_Config_IniTest.php @@ -0,0 +1,100 @@ + + * + * Este programa software livre; voc pode redistribu-lo e/ou modific-lo + * sob os termos da Licena Pblica Geral GNU conforme publicada pela Free + * Software Foundation; tanto a verso 2 da Licena, como (a seu critrio) + * qualquer verso posterior. + * + * Este programa distribudo na expectativa de que seja til, porm, SEM + * NENHUMA GARANTIA; nem mesmo a garantia implcita de COMERCIABILIDADE OU + * ADEQUAO A UMA FINALIDADE ESPECFICA. Consulte a Licena Pblica Geral + * do GNU para mais detalhes. + * + * Voc deve ter recebido uma cpia da Licena Pblica Geral do GNU junto + * com este programa; se no, escreva para a Free Software Foundation, Inc., no + * endereo 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. + * + * @author Eriksen Costa Paixo + * @category i-Educar + * @license @@license@@ + * @package CoreExt + * @subpackage UnitTests + * @since Arquivo disponvel desde a verso 1.1.0 + * @version $Id$ + */ + +require_once 'CoreExt/Config/Ini.class.php'; + +/** + * CoreExt_Config_IniTest class. + * + * @author Eriksen Costa Paixo + * @category i-Educar + * @license @@license@@ + * @package CoreExt + * @subpackage UnitTests + * @since Classe disponvel desde a verso 1.1.0 + * @version @@package_version@@ + */ +class CoreExt_Config_IniTest extends UnitBaseTest +{ + public function testParsedIni() + { + $ini = new CoreExt_Config_Ini('../tests/fixtures/configuration/ieducar.ini'); + $this->assertNotNull($ini->app); + } + + public function testChangeEnviroment() + { + $ini = new CoreExt_Config_Ini('../tests/fixtures/configuration/ieducar.ini'); + $this->assertEquals(FALSE, (bool) $ini->php->display_errors); + + $ini->changeEnviroment('development'); + $this->assertEquals(TRUE, (bool) $ini->php->display_errors); + + $ini->changeEnviroment('testing'); + $this->assertEquals(TRUE, (bool) $ini->php->display_errors); + + $ini->changeEnviroment(); + $this->assertEquals(FALSE, (bool) $ini->php->display_errors); + } + + /** + * @expectedException Exception + */ + public function testInvalidIniFile() + { + // Tentando carregar configurao do blackhole! + $ini = new CoreExt_Config_Ini('/dev/null'); + } + + /** + * @expectedException Exception + */ + public function testSectionExtendsMoreThanOne() + { + $ini = new CoreExt_Config_Ini('../tests/fixtures/configuration/ieducar-extends-broken.ini'); + } + + /** + * @expectedException Exception + */ + public function testIniSyntaxError() + { + $ini = new CoreExt_Config_Ini('../tests/fixtures/configuration/ieducar-syntax-broken.ini'); + } + + /** + * @expectedException Exception + */ + public function testSectionInheritanceNotExist() + { + $ini = new CoreExt_Config_Ini('../tests/fixtures/configuration/ieducar-inheritance-broken.ini'); + } +} \ No newline at end of file diff --git a/ieducar/tests/unit/CoreExt_ConfigTest.class.php b/ieducar/tests/unit/CoreExt_ConfigTest.class.php deleted file mode 100644 index 1aa401c..0000000 --- a/ieducar/tests/unit/CoreExt_ConfigTest.class.php +++ /dev/null @@ -1,137 +0,0 @@ - - * - * Este programa software livre; voc pode redistribu-lo e/ou modific-lo - * sob os termos da Licena Pblica Geral GNU conforme publicada pela Free - * Software Foundation; tanto a verso 2 da Licena, como (a seu critrio) - * qualquer verso posterior. - * - * Este programa distribudo na expectativa de que seja til, porm, SEM - * NENHUMA GARANTIA; nem mesmo a garantia implcita de COMERCIABILIDADE OU - * ADEQUAO A UMA FINALIDADE ESPECFICA. Consulte a Licena Pblica Geral - * do GNU para mais detalhes. - * - * Voc deve ter recebido uma cpia da Licena Pblica Geral do GNU junto - * com este programa; se no, escreva para a Free Software Foundation, Inc., no - * endereo 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. - */ - -require_once realpath(dirname(__FILE__) . '/../') . '/UnitBaseTest.class.php'; -require_once '../lib/CoreExt/Config.class.php'; - - -/** - * CoreExt_ConfigTest class - * - * @author Eriksen Costa Paixo - * @license http://creativecommons.org/licenses/GPL/2.0/legalcode.pt CC GNU GPL - * @package Test - * @since Classe disponvel desde a verso 1.1.0 - * @version $Id$ - */ -class CoreExt_ConfigTest extends UnitBaseTest -{ - - public function testConfigHasValueFromArray() - { - $arr = array( - 'app' => array( - 'database' => array( - 'dbname' => 'ieducardb', - 'username' => 'ieducaruser', - 'password' => '12345678' - ) - ), - 'version' => 'Development' - ); - - $config = new CoreExt_Config($arr); - $this->assertEquals('ieducardb', $config->app->database->dbname); - $this->assertEquals('Development', $config->version); - } - - public function testHasOneItem() - { - $arr = array( - 'app' => array('database' => '') - ); - - $config = new CoreExt_Config($arr); - $this->assertEquals(1, $config->count()); - } - - public function testHasTwoItems() { - $arr = array( - 'app' => array('database' => '', 'template' => ''), - 'php' => '' - ); - - $config = new CoreExt_Config($arr); - $this->assertEquals(2, $config->count()); - $this->assertEquals(2, $config->app->count()); - } - - /** - * @expectedException Exception - */ - public function testGetNotExistNotProvidingDefaultValue() - { - $arr = array('app' => array('database' => array('dbname' => 'ieducardb'))); - - $config = new CoreExt_Config($arr); - $hostname = $config->get($config->app->database->hostname); - $this->assertEquals($hostname, '127.0.0.1'); - } - - public function testGetNotExistProvidingDefaultValue() - { - $arr = array('app' => array('database' => array('dbname' => 'ieducardb'))); - - $config = new CoreExt_Config($arr); - $hostname = $config->get($config->app->database->hostname, '127.0.0.1'); - $this->assertEquals($hostname, '127.0.0.1'); - } - - public function testGetExistProvidingDefaultValue() - { - $arr = array('app' => array('database' => array('dbname' => 'ieducardb'))); - - $config = new CoreExt_Config($arr); - $hostname = $config->get($config->app->database->dbname, '127.0.0.1'); - $this->assertEquals($hostname, 'ieducardb'); - } - - public function testObjectIterates() - { - $arr = array( - 'index1' => 1, - 'index2' => 2 - ); - - $config = new CoreExt_Config($arr); - - $this->assertEquals(1, $config->current()); - - $config->next(); - $this->assertEquals(2, $config->current()); - - foreach ($config as $key => $val) {} - - $config->rewind(); - $this->assertEquals(1, $config->current()); - } - - public function testTransformObjectInArray() { - $arr = array(6, 3, 3); - - $config = new CoreExt_Config($arr); - - $this->assertEquals($arr, $config->toArray()); - } - -} \ No newline at end of file diff --git a/ieducar/tests/unit/CoreExt_Config_IniTest.class.php b/ieducar/tests/unit/CoreExt_Config_IniTest.class.php deleted file mode 100644 index 9908ac2..0000000 --- a/ieducar/tests/unit/CoreExt_Config_IniTest.class.php +++ /dev/null @@ -1,89 +0,0 @@ - - * - * Este programa software livre; voc pode redistribu-lo e/ou modific-lo - * sob os termos da Licena Pblica Geral GNU conforme publicada pela Free - * Software Foundation; tanto a verso 2 da Licena, como (a seu critrio) - * qualquer verso posterior. - * - * Este programa distribudo na expectativa de que seja til, porm, SEM - * NENHUMA GARANTIA; nem mesmo a garantia implcita de COMERCIABILIDADE OU - * ADEQUAO A UMA FINALIDADE ESPECFICA. Consulte a Licena Pblica Geral - * do GNU para mais detalhes. - * - * Voc deve ter recebido uma cpia da Licena Pblica Geral do GNU junto - * com este programa; se no, escreva para a Free Software Foundation, Inc., no - * endereo 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. - */ - -require_once realpath(dirname(__FILE__) . '/../') . '/UnitBaseTest.class.php'; -require_once '../lib/CoreExt/Config/Ini.class.php'; - - -/** - * CoreExt_Config_IniTest class - * - * @author Eriksen Costa Paixo - * @license http://creativecommons.org/licenses/GPL/2.0/legalcode.pt CC GNU GPL - * @package Test - * @since Classe disponvel desde a verso 1.1.0 - * @version $Id$ - */ -class CoreExt_Config_IniTest extends UnitBaseTest -{ - - public function testParsedIni() { - $ini = new CoreExt_Config_Ini('../tests/fixtures/configuration/ieducar.ini'); - $this->assertNotNull($ini->app); - } - - public function testChangeEnviroment() - { - $ini = new CoreExt_Config_Ini('../tests/fixtures/configuration/ieducar.ini'); - $this->assertEquals(FALSE, (bool) $ini->php->display_errors); - - $ini->changeEnviroment('development'); - $this->assertEquals(TRUE, (bool) $ini->php->display_errors); - - $ini->changeEnviroment('testing'); - $this->assertEquals(TRUE, (bool) $ini->php->display_errors); - - $ini->changeEnviroment(); - $this->assertEquals(FALSE, (bool) $ini->php->display_errors); - } - - /** - * @expectedException Exception - */ - public function testInvalidIniFile() { - // Tentando carregar configurao do blackhole! - $ini = new CoreExt_Config_Ini('/dev/null'); - } - - /** - * @expectedException Exception - */ - public function testSectionExtendsMoreThanOne() { - $ini = new CoreExt_Config_Ini('../tests/fixtures/configuration/ieducar-extends-broken.ini'); - } - - /** - * @expectedException Exception - */ - public function testIniSyntaxError() { - $ini = new CoreExt_Config_Ini('../tests/fixtures/configuration/ieducar-syntax-broken.ini'); - } - - /** - * @expectedException Exception - */ - public function testSectionInheritanceNotExist() { - $ini = new CoreExt_Config_Ini('../tests/fixtures/configuration/ieducar-inheritance-broken.ini'); - } - -} \ No newline at end of file diff --git a/ieducar/tests/unit/FileStreamTest.class.php b/ieducar/tests/unit/FileStreamTest.class.php deleted file mode 100644 index 278c269..0000000 --- a/ieducar/tests/unit/FileStreamTest.class.php +++ /dev/null @@ -1,157 +0,0 @@ - - * - * Este programa software livre; voc pode redistribu-lo e/ou modific-lo - * sob os termos da Licena Pblica Geral GNU conforme publicada pela Free - * Software Foundation; tanto a verso 2 da Licena, como (a seu critrio) - * qualquer verso posterior. - * - * Este programa distribudo na expectativa de que seja til, porm, SEM - * NENHUMA GARANTIA; nem mesmo a garantia implcita de COMERCIABILIDADE OU - * ADEQUAO A UMA FINALIDADE ESPECFICA. Consulte a Licena Pblica Geral - * do GNU para mais detalhes. - * - * Voc deve ter recebido uma cpia da Licena Pblica Geral do GNU junto - * com este programa; se no, escreva para a Free Software Foundation, Inc., no - * endereo 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. - */ - -require_once realpath(dirname(__FILE__) . '/../') . '/UnitBaseTest.class.php'; -require_once 'vfsStream/vfsStream.php'; -require_once 'Utils/FileStream.class.php'; -require_once 'Utils/Mimetype.class.php'; - - -/** - * FileStreamTest class. - * - * @author Eriksen Costa Paixo - * @license http://creativecommons.org/licenses/GPL/2.0/legalcode.pt CC GNU GPL - * @link http://code.google.com/p/bovigo/wiki/vfsStream vfsStream project - * @package Test - * @since Classe disponvel desde a verso 1.1.0 - * @version $Id$ - */ -class FileStreamTest extends UnitBaseTest -{ - - protected $Mimetype = NULL; - - protected function setUp() { - $this->Mimetype = new Mimetype(); - } - - protected function configVfs() { - vfsStreamWrapper::register(); - vfsStreamWrapper::setRoot(new vfsStreamDirectory('tmp')); - } - - public function testAllowedDirectory() - { - $directories = array('pdf', 'tmp'); - - $fileStream = new FileStream($this->Mimetype, $directories); - $this->assertTrue($fileStream->isDirectoryAllowed('pdf')); - } - - public function testDisallowedDirectory() - { - $fileStream = new FileStream($this->Mimetype); - $this->assertFalse($fileStream->isDirectoryAllowed('pdf')); - } - - /** - * @expectedException Exception - */ - public function testSetFileDirectoryDisallowed() - { - $filename = 'pdf/example.pdf'; - $fileStream = new FileStream($this->Mimetype, array('tmp')); - - $fileStream->setFilepath($filename); - } - - /** - * @expectedException Exception - */ - public function testSetFileDirectoryAllowed() - { - $filename = 'tmp/example.pdf'; - $fileStream = new FileStream($this->Mimetype, array('tmp')); - - $fileStream->setFilepath($filename); - } - - public function testSetFile() - { - $this->configVfs(); - - // Nome do arquivo - $filename = 'tmp/example.pdf'; - - // Adiciona o schema vfs:// ao caminho do arquivo - $filepath = vfsStream::url($filename); - - // Cria um novo arquivo no vfs - fopen($filepath, 'a+'); - - // Pega o nome do diretrio e coloca em array - $directory = (array) vfsStream::url(vfsStreamWrapper::getRoot()->getName()); - - $fileStream = new FileStream($this->Mimetype, $directory); - $fileStream->setFilepath($filepath); - } - - /** - * @expectedException Exception - */ - public function testStreamFileExtensionNotSupported() - { - $this->configVfs(); - $filename = 'tmp/example.dummy'; - $filepath = vfsStream::url($filename); - fopen($filepath, 'a+'); - $directory = (array) vfsStream::url(vfsStreamWrapper::getRoot()->getName()); - - $stub = $this->getMock('Mimetype'); - $stub->expects($this->once()) - ->method('getType') - ->will($this->returnValue(FALSE)); - - $fileStream = new FileStream($stub, $directory); - $fileStream->setFilepath($filepath); - - $fileStream->streamFile(); - } - - /** - * Tag disponvel apenas no PHPUnit 3.4, ainda no disponvel no pacote - * Pear PHPUnit-beta3. Note o uso do '@' para supresso das mensagens de - * erro. - * - * @outputBuffering enabled - */ - public function testStreamFileExtensionSupported() - { - $this->configVfs(); - $filename = 'tmp/example.pdf'; - $filepath = vfsStream::url($filename); - fopen($filepath, 'a+'); - $directory = (array) vfsStream::url(vfsStreamWrapper::getRoot()->getName()); - - $stub = $this->getMock('Mimetype'); - $stub->expects($this->once()) - ->method('getType') - ->will($this->returnValue('application/pdf')); - - $fileStream = new FileStream($stub, $directory); - $fileStream->setFilepath($filepath); - @$fileStream->streamFile(); - } - -} diff --git a/ieducar/tests/unit/Utils/AllTests.php b/ieducar/tests/unit/Utils/AllTests.php new file mode 100644 index 0000000..f4b9696 --- /dev/null +++ b/ieducar/tests/unit/Utils/AllTests.php @@ -0,0 +1,55 @@ + + * + * Este programa software livre; voc pode redistribu-lo e/ou modific-lo + * sob os termos da Licena Pblica Geral GNU conforme publicada pela Free + * Software Foundation; tanto a verso 2 da Licena, como (a seu critrio) + * qualquer verso posterior. + * + * Este programa distribudo na expectativa de que seja til, porm, SEM + * NENHUMA GARANTIA; nem mesmo a garantia implcita de COMERCIABILIDADE OU + * ADEQUAO A UMA FINALIDADE ESPECFICA. Consulte a Licena Pblica Geral + * do GNU para mais detalhes. + * + * Voc deve ter recebido uma cpia da Licena Pblica Geral do GNU junto + * com este programa; se no, escreva para a Free Software Foundation, Inc., no + * endereo 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. + * + * @author Eriksen Costa Paixo + * @category i-Educar + * @license @@license@@ + * @package Utils + * @subpackage UnitTests + * @since Arquivo disponvel desde a verso 1.1.0 + * @version $Id$ + */ + +/** + * Utils_AllTests class. + * + * Arquivo de definio de sute para o pacote Utils. + * + * @author Eriksen Costa Paixo + * @category i-Educar + * @license @@license@@ + * @package Utils + * @subpackage UnitTests + * @since Classe disponvel desde a verso 1.1.0 + * @version @@package_version@@ + */ +class Utils_AllTests extends TestCollector +{ + protected $_name = 'Sute de testes unitrios de Utils (pacote de transio)'; + protected $_file = __FILE__; + + public static function suite() + { + $instance = new self; + return $instance->addDirectoryTests(); + } +} \ No newline at end of file diff --git a/ieducar/tests/unit/Utils/FileStreamTest.php b/ieducar/tests/unit/Utils/FileStreamTest.php new file mode 100644 index 0000000..684c082 --- /dev/null +++ b/ieducar/tests/unit/Utils/FileStreamTest.php @@ -0,0 +1,164 @@ + + * + * Este programa software livre; voc pode redistribu-lo e/ou modific-lo + * sob os termos da Licena Pblica Geral GNU conforme publicada pela Free + * Software Foundation; tanto a verso 2 da Licena, como (a seu critrio) + * qualquer verso posterior. + * + * Este programa distribudo na expectativa de que seja til, porm, SEM + * NENHUMA GARANTIA; nem mesmo a garantia implcita de COMERCIABILIDADE OU + * ADEQUAO A UMA FINALIDADE ESPECFICA. Consulte a Licena Pblica Geral + * do GNU para mais detalhes. + * + * Voc deve ter recebido uma cpia da Licena Pblica Geral do GNU junto + * com este programa; se no, escreva para a Free Software Foundation, Inc., no + * endereo 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. + * + * @author Eriksen Costa Paixo + * @category i-Educar + * @license @@license@@ + * @package Utils + * @subpackage UnitTests + * @since Arquivo disponvel desde a verso 1.1.0 + * @version $Id$ + */ + +require_once 'UnitBaseTest.class.php'; +require_once 'vfsStream/vfsStream.php'; +require_once 'Utils/FileStream.class.php'; +require_once 'Utils/Mimetype.class.php'; + + +/** + * FileStreamTest class. + * + * @author Eriksen Costa Paixo + * @category i-Educar + * @license @@license@@ + * @package Utils + * @subpackage UnitTests + * @since Classe disponvel desde a verso 1.1.0 + * @version @@package_version@@ + */ +class FileStreamTest extends UnitBaseTest +{ + protected $Mimetype = NULL; + + protected function setUp() + { + $this->Mimetype = new Mimetype(); + } + + protected function configVfs() + { + vfsStreamWrapper::register(); + vfsStreamWrapper::setRoot(new vfsStreamDirectory('tmp')); + } + + public function testAllowedDirectory() + { + $directories = array('pdf', 'tmp'); + + $fileStream = new FileStream($this->Mimetype, $directories); + $this->assertTrue($fileStream->isDirectoryAllowed('pdf')); + } + + public function testDisallowedDirectory() + { + $fileStream = new FileStream($this->Mimetype); + $this->assertFalse($fileStream->isDirectoryAllowed('pdf')); + } + + /** + * @expectedException Exception + */ + public function testSetFileDirectoryDisallowed() + { + $filename = 'pdf/example.pdf'; + $fileStream = new FileStream($this->Mimetype, array('tmp')); + $fileStream->setFilepath($filename); + } + + /** + * @expectedException Exception + */ + public function testSetFileDirectoryAllowed() + { + $filename = 'tmp/example.pdf'; + $fileStream = new FileStream($this->Mimetype, array('tmp')); + $fileStream->setFilepath($filename); + } + + public function testSetFile() + { + $this->configVfs(); + + // Nome do arquivo + $filename = 'tmp/example.pdf'; + + // Adiciona o schema vfs:// ao caminho do arquivo + $filepath = vfsStream::url($filename); + + // Cria um novo arquivo no vfs + fopen($filepath, 'a+'); + + // Pega o nome do diretrio e coloca em array + $directory = (array) vfsStream::url(vfsStreamWrapper::getRoot()->getName()); + + $fileStream = new FileStream($this->Mimetype, $directory); + $fileStream->setFilepath($filepath); + } + + /** + * @expectedException Exception + */ + public function testStreamFileExtensionNotSupported() + { + $this->configVfs(); + $filename = 'tmp/example.dummy'; + $filepath = vfsStream::url($filename); + fopen($filepath, 'a+'); + $directory = (array) vfsStream::url(vfsStreamWrapper::getRoot()->getName()); + + $stub = $this->getMock('Mimetype'); + $stub->expects($this->once()) + ->method('getType') + ->will($this->returnValue(FALSE)); + + $fileStream = new FileStream($stub, $directory); + $fileStream->setFilepath($filepath); + + $fileStream->streamFile(); + } + + /** + * Tag disponvel apenas no PHPUnit 3.4, ainda no disponvel no pacote + * Pear PHPUnit-beta3. Note o uso do '@' para supresso das mensagens de + * erro. + * + * @outputBuffering enabled + */ + public function testStreamFileExtensionSupported() + { + $this->configVfs(); + $filename = 'tmp/example.pdf'; + $filepath = vfsStream::url($filename); + fopen($filepath, 'a+'); + $directory = (array) vfsStream::url(vfsStreamWrapper::getRoot()->getName()); + + $stub = $this->getMock('Mimetype'); + $stub->expects($this->once()) + ->method('getType') + ->will($this->returnValue('application/pdf')); + + $fileStream = new FileStream($stub, $directory); + $fileStream->setFilepath($filepath); + @$fileStream->streamFile(); + } +} \ No newline at end of file -- libgit2 0.21.2