Commit b439eef071e21026436be8fc67d1a07580dbc17d
1 parent
e90ab4b1
Exists in
master
by Eriksen: Refactoring no diretório {{{tests/}}}:
* Criado suíte de testes geral para o projeto e específicas para cada tipo (unitário ou funcional) e de pacote ({{{tests/unit/App}}}, por exemplo). Exemplos(assumindo raiz do projeto): * {{{phpunit tests/AllTests.php}}} - executa a suíte inteira de testes * {{{phpunit tests/unit/AllTests.php}}} - executa a suíte de testes unitários * {{{phpunit tests/unit/CoreExt/AllTests.php}}} - executa a suíte de testes unitários do pacote {{{CoreExt}}} * Observação: por esse motivo, a task phing alltests, unittests e functests foram removidas do buildfile * Atualização da convenção de nomeação de arquivos: ao invés de {{{.class.php}}}, arquivos deverão ser renomeados como {{{.php}}} * Atualização dos docblocks dos arquivos e classes de testes: * Tag {{{@category}}} tem o valor i-Educar, não importa em qual pacote o arquivo/classe está * Testes unitários estão no {{{@subpackage UnitTests}}} e funcionais em {{{@subpackage FunctionalTests}}} * Os testes unitários foram movidos para subdiretórios respeitando a organização de diretórios global: * Teste de classes legadas (por exemplo, as classes do diretório {{{intranet/}}} estão no diretório {{{tests/unit/Core}}} * Analogamente, classes de teste unitário da nova API {{{CoreExt}}}, classes utilitárias {{{Utils}}} e das novas classes da aplicação {{{App}}} estão nos diretórios {{{tests/unit/CoreExt}}}, {{{tests/unit/Utils}}} e {{{tests/unit/App}}} * Os pacotes de cada classe deve obedecer ao pacote da classe ao qual testa, por exemplo, se {{{lib/CoreExt/Config.class.php (CoreExt_Config)}}} está no pacote {{{CoreExt_Config}}}, {{{tests/unit/CoreExt/ConfigTest.php (CoreExt_ConfigTest)}}} deverá estar no mesmo pacote * Classe {{{TestCollector}}} criada para auxiliar na criação de suíte de testes * Arquivo {{{tests/bootstrap.php}}} criado para configurar o ambiente adequadamente para testes * Arquivo {{{phpunit.xml}}} atualizado para usar o arquivo {{{tests/bootstrap.php}}} * Buildfile atualizado. Tarefas alltests, unittests, functests foram removidos devido a inclusão dos arquivos {{{bootstrap.php}}} e das suítes {{{AllTests}}}
Showing
33 changed files
with
1743 additions
and
927 deletions
Show diff stats
ieducar/misc/build.xml
1 | <?xml version="1.0"?> | 1 | <?xml version="1.0"?> |
2 | - | ||
3 | -<!-- | ||
4 | - - Configurações para o processo de build Phing | ||
5 | - - | ||
6 | - - Este arquivo de build precisa de alguns ajustes antes da criação de uma | ||
7 | - - release. Mude a propriedade project.conf.version para o número de versão | ||
8 | - - desejado e a propriedade project.conf.buildin para apontar para o diretório | ||
9 | - - de build desejado (o padrão é /tmp). | ||
10 | - - | ||
11 | - - Dois pacotes compactados serão criados, um Gzip e outro Zip. | ||
12 | - - | ||
13 | - - Este build não executa os testes unitários e funcionais. | ||
14 | - - | ||
15 | - - Arquivo codificado em UTF-8 para maior compatibilidade com o utilitário | ||
16 | - - CLI phing. | ||
17 | - - | ||
18 | - - @author Eriksen Costa Paixão <eriksen.paixao_bs@cobra.com.br> | ||
19 | - - @license http://creativecommons.org/licenses/GPL/2.0/legalcode.pt CC GNU GPL | ||
20 | - - @link http://phing.info/docs/guide/current/ Phing Documentation | ||
21 | - - @version $Id$ | ||
22 | - --> | ||
23 | - | ||
24 | -<project name="i-Educar" description="Sistema de gestão de escolas" default="release" basedir="../"> | 2 | +<!-- |
3 | +/** | ||
4 | + * Configurações para o processo de build Phing | ||
5 | + * | ||
6 | + * Este arquivo de build precisa de alguns ajustes antes da criação de uma | ||
7 | + * release. Mude a propriedade project.conf.version para o número de versão | ||
8 | + * desejado e a propriedade project.conf.buildin para apontar para o diretório | ||
9 | + * de build desejado (o padrão é /tmp). | ||
10 | + * | ||
11 | + * Dois pacotes compactados serão criados, um Gzip e outro Zip. | ||
12 | + * | ||
13 | + * Este build não executa os testes unitários e funcionais. | ||
14 | + * | ||
15 | + * Arquivo codificado em UTF-8 para maior compatibilidade com o utilitário | ||
16 | + * CLI phing. | ||
17 | + * | ||
18 | + * @author Eriksen Costa Paixão <eriksen.paixao_bs@cobra.com.br> | ||
19 | + * @license http://creativecommons.org/licenses/GPL/2.0/legalcode.pt CC GNU GPL | ||
20 | + * @link http://phing.info/docs/guide/current/ Phing Documentation | ||
21 | + * @todo Incluir tarefas de geração de API (PhpDocumentorTask) | ||
22 | + * @version $Id$ | ||
23 | + */ | ||
24 | +--> | ||
25 | +<project name="i-Educar" description="Sistema de gestão escolar" default="release" basedir="../"> | ||
26 | + <!-- Configuração geral do build --> | ||
25 | <property name="project.conf.version" value="1.1.0" /> | 27 | <property name="project.conf.version" value="1.1.0" /> |
26 | <property name="project.conf.curdir" value="" /> | 28 | <property name="project.conf.curdir" value="" /> |
27 | <property name="project.conf.buildin" value="/tmp" /> | 29 | <property name="project.conf.buildin" value="/tmp" /> |
@@ -34,13 +36,54 @@ | @@ -34,13 +36,54 @@ | ||
34 | <property name="project.conf.dbdeploy.username" value="ieducar" /> | 36 | <property name="project.conf.dbdeploy.username" value="ieducar" /> |
35 | <property name="project.conf.dbdeploy.password" value="ieducar" /> | 37 | <property name="project.conf.dbdeploy.password" value="ieducar" /> |
36 | <property name="project.conf.dbdeploy.dbname" value="ieducar" /> | 38 | <property name="project.conf.dbdeploy.dbname" value="ieducar" /> |
37 | - <property name="project.conf.dbdeploy.psql_path" value="/usr/bin/psql" /> | 39 | + <property name="project.conf.dbdeploy.psql_path" value="" /> |
40 | + | ||
41 | + <!-- Variáveis para substituição de tokens --> | ||
42 | + <property name="project.conf.license" value="http://creativecommons.org/licenses/GPL/2.0/legalcode.pt CC GNU GPL" /> | ||
38 | 43 | ||
39 | <!-- Apenas para saber quanta memória o build consome --> | 44 | <!-- Apenas para saber quanta memória o build consome --> |
40 | <property name="build.report.memory_peak" value="" /> | 45 | <property name="build.report.memory_peak" value="" /> |
41 | 46 | ||
47 | + <!-- project.conf.dbdeploy.psql --> | ||
48 | + <!-- | ||
49 | + Procura pelo psql no path do sistema. | ||
50 | + | ||
51 | + O comando which retorna um status code. Para saber qual o comando | ||
52 | + registrado no $PATH, gravamos para um arquivo, recuperamos o seu conteúdo | ||
53 | + e gravamos o valor em ${project.conf.dbdeploy.psql_path}. | ||
54 | + --> | ||
55 | + <exec command="which psql > ${project.conf.buildin}/psql_path.txt" escape="false" /> | ||
56 | + | ||
57 | + <php function="file_get_contents" returnProperty="project.conf.dbdeploy.psql_path"> | ||
58 | + <param value="${project.conf.buildin}/psql_path.txt" /> | ||
59 | + </php> | ||
60 | + | ||
61 | + <php function="trim" returnProperty="project.conf.dbdeploy.psql_path"> | ||
62 | + <param value="${project.conf.dbdeploy.psql_path}" /> | ||
63 | + </php> | ||
64 | + <!-- /project.conf.dbdeploy.psql --> | ||
65 | + | ||
42 | <!-- Pega o diretório atual como workaround ao chdir das classes de teste base --> | 66 | <!-- Pega o diretório atual como workaround ao chdir das classes de teste base --> |
43 | <php function="getcwd" returnProperty="project.conf.curdir" /> | 67 | <php function="getcwd" returnProperty="project.conf.curdir" /> |
68 | + | ||
69 | + <!-- project.conf.release_hash --> | ||
70 | + <!-- | ||
71 | + Gera um hash único no momento do build para uso como chave de geração de | ||
72 | + Id de sessão. Ver: http://php.net/session_id | ||
73 | + --> | ||
74 | + <php function="time" returnProperty="project.conf.timestamp" /> | ||
75 | + | ||
76 | + <!-- Gera um uniqid --> | ||
77 | + <php function="uniqid" returnProperty="project.conf.uniqid"> | ||
78 | + <param value="${project.conf.version}-${project.conf.timestamp}" /> | ||
79 | + <param value="TRUE" /> | ||
80 | + </php> | ||
81 | + | ||
82 | + <!-- Hash sha1 do uniqid para distribuição --> | ||
83 | + <php function="sha1" returnProperty="project.conf.hash"> | ||
84 | + <param value="${project.conf.uniqid}" /> | ||
85 | + </php> | ||
86 | + <!-- /project.conf.release_hash --> | ||
44 | 87 | ||
45 | <!-- Inclui todos os arquivos do projeto, ignorando alguns arquivos e diretórios --> | 88 | <!-- Inclui todos os arquivos do projeto, ignorando alguns arquivos e diretórios --> |
46 | <fileset dir="${project.basedir}" id="allfiles"> | 89 | <fileset dir="${project.basedir}" id="allfiles"> |
@@ -54,33 +97,13 @@ | @@ -54,33 +97,13 @@ | ||
54 | <exclude name="misc/database/deltas/**" /> | 97 | <exclude name="misc/database/deltas/**" /> |
55 | </fileset> | 98 | </fileset> |
56 | 99 | ||
57 | - <!-- Inclui todos os arquivos de testes --> | ||
58 | - <fileset dir="${project.conf.curdir}/tests" id="alltests"> | ||
59 | - <include name="**" /> | ||
60 | - <exclude name="selenese/*" /> | ||
61 | - </fileset> | ||
62 | - | ||
63 | - <!-- Inclui apenas os arquivos de unit test --> | ||
64 | - <fileset dir="${project.conf.curdir}/tests" id="unittests"> | ||
65 | - <include name="**" /> | ||
66 | - <exclude name="functional/*" /> | ||
67 | - <exclude name="selenese/*" /> | ||
68 | - </fileset> | ||
69 | - | ||
70 | - <!-- Inclui apenas os arquivos de functional test --> | ||
71 | - <fileset dir="${project.conf.curdir}/tests" id="functests"> | ||
72 | - <include name="**" /> | ||
73 | - <exclude name="unit/*" /> | ||
74 | - <exclude name="selenese/*" /> | ||
75 | - </fileset> | ||
76 | - | ||
77 | <!-- Prepara o ambiente para a o processo de build --> | 100 | <!-- Prepara o ambiente para a o processo de build --> |
78 | <target name="prepare"> | 101 | <target name="prepare"> |
79 | <echo msg="Preparando o build para a release ${project.conf.version}" /> | 102 | <echo msg="Preparando o build para a release ${project.conf.version}" /> |
80 | 103 | ||
81 | <echo msg="Apagando diretório alvo ${project.conf.builddir}" /> | 104 | <echo msg="Apagando diretório alvo ${project.conf.builddir}" /> |
82 | <delete dir="${project.conf.builddir}" verbose="on" includeemptydirs="on" failonerror="on" /> | 105 | <delete dir="${project.conf.builddir}" verbose="on" includeemptydirs="on" failonerror="on" /> |
83 | - | 106 | + |
84 | <echo msg="Apagando pacotes gzip e zip ${project.conf.buildgzip} e ${project.conf.buildzip}" /> | 107 | <echo msg="Apagando pacotes gzip e zip ${project.conf.buildgzip} e ${project.conf.buildzip}" /> |
85 | <delete file="${project.conf.buildgzip}" verbose="on" failonerror="on" /> | 108 | <delete file="${project.conf.buildgzip}" verbose="on" failonerror="on" /> |
86 | <delete file="${project.conf.buildzip}" verbose="on" failonerror="on" /> | 109 | <delete file="${project.conf.buildzip}" verbose="on" failonerror="on" /> |
@@ -91,37 +114,6 @@ | @@ -91,37 +114,6 @@ | ||
91 | <mkdir dir="${project.conf.builddir}/deploy" /> | 114 | <mkdir dir="${project.conf.builddir}/deploy" /> |
92 | </target> | 115 | </target> |
93 | 116 | ||
94 | - <!-- Executa todos os testes disponíveis --> | ||
95 | - <target name="tests"> | ||
96 | - <echo msg="Executando todos os testes em ${project.conf.curdir}/tests" /> | ||
97 | - <phpunit printsummary="true" haltonfailure="true" haltonerror="on" > | ||
98 | - <formatter todir="${project.conf.buildin}" type="xml"/> | ||
99 | - <batchtest> | ||
100 | - <fileset refid="alltests" /> | ||
101 | - </batchtest> | ||
102 | - </phpunit> | ||
103 | - </target> | ||
104 | - | ||
105 | - <!-- Executa apenas os unit tests --> | ||
106 | - <target name="unittest"> | ||
107 | - <echo msg="Executando todos os unit tests em ${project.conf.curdir}/tests/unit" /> | ||
108 | - <phpunit printsummary="true" haltonfailure="true" haltonerror="on" > | ||
109 | - <batchtest> | ||
110 | - <fileset refid="unittests" /> | ||
111 | - </batchtest> | ||
112 | - </phpunit> | ||
113 | - </target> | ||
114 | - | ||
115 | - <!-- Executa apenas os functional tests --> | ||
116 | - <target name="functest"> | ||
117 | - <echo msg="Executando todos os functional tests em ${project.conf.curdir}/tests/functional" /> | ||
118 | - <phpunit printsummary="true" haltonfailure="true" haltonerror="on" > | ||
119 | - <batchtest> | ||
120 | - <fileset refid="functests" /> | ||
121 | - </batchtest> | ||
122 | - </phpunit> | ||
123 | - </target> | ||
124 | - | ||
125 | <!-- Tarefa de migração de banco de dados --> | 117 | <!-- Tarefa de migração de banco de dados --> |
126 | <target name="migrate" description="Migração de BD" depends="prepare"> | 118 | <target name="migrate" description="Migração de BD" depends="prepare"> |
127 | 119 | ||
@@ -132,28 +124,34 @@ | @@ -132,28 +124,34 @@ | ||
132 | <property name="project.conf.dbdeploy.deployfile" value="deploy/deploy.sql" /> | 124 | <property name="project.conf.dbdeploy.deployfile" value="deploy/deploy.sql" /> |
133 | <property name="project.conf.dbdeploy.undofile" value="deploy/undo.sql" /> | 125 | <property name="project.conf.dbdeploy.undofile" value="deploy/undo.sql" /> |
134 | 126 | ||
135 | - <!-- generate the deployment scripts --> | ||
136 | - <dbdeploy | ||
137 | - url="pgsql:host=${project.conf.dbdeploy.hostname};dbname=${project.conf.dbdeploy.dbname}" | ||
138 | - userid="${project.conf.dbdeploy.username}" | ||
139 | - password="${project.conf.dbdeploy.password}" | ||
140 | - dir="${project.conf.curdir}/misc/database/deltas" | ||
141 | - outputfile="${project.conf.builddir}/${project.conf.dbdeploy.deployfile}" | 127 | + <!-- Gera os scripts de dbdeploy --> |
128 | + <dbdeploy | ||
129 | + url="pgsql:host=${project.conf.dbdeploy.hostname};dbname=${project.conf.dbdeploy.dbname}" | ||
130 | + userid="${project.conf.dbdeploy.username}" | ||
131 | + password="${project.conf.dbdeploy.password}" | ||
132 | + dir="${project.conf.curdir}/misc/database/deltas" | ||
133 | + outputfile="${project.conf.builddir}/${project.conf.dbdeploy.deployfile}" | ||
142 | undooutputfile="${project.conf.builddir}/${project.conf.dbdeploy.undofile}" /> | 134 | undooutputfile="${project.conf.builddir}/${project.conf.dbdeploy.undofile}" /> |
143 | 135 | ||
144 | <!-- Executa o psql através de chamada shell, por velocidade --> | 136 | <!-- Executa o psql através de chamada shell, por velocidade --> |
145 | - <exec | ||
146 | - command="${project.conf.dbdeploy.psql_path} -U ${project.conf.dbdeploy.username} ${project.conf.dbdeploy.dbname} < ${project.conf.dbdeploy.deployfile}" | ||
147 | - dir="${project.conf.builddir}" | 137 | + <exec |
138 | + command="${project.conf.dbdeploy.psql_path} -U ${project.conf.dbdeploy.username} ${project.conf.dbdeploy.dbname} < ${project.conf.dbdeploy.deployfile}" | ||
139 | + dir="${project.conf.builddir}" | ||
148 | checkreturn="true" /> | 140 | checkreturn="true" /> |
149 | </target> | 141 | </target> |
150 | - | ||
151 | 142 | ||
152 | <!-- Copia os arquivos do projeto para o diretório de build --> | 143 | <!-- Copia os arquivos do projeto para o diretório de build --> |
153 | <target name="build" depends="prepare"> | 144 | <target name="build" depends="prepare"> |
154 | <echo msg="Criando o build" /> | 145 | <echo msg="Criando o build" /> |
155 | <delete dir="${project.conf.builddir}/deploy" verbose="on" includeemptydirs="on" failonerror="on" /> | 146 | <delete dir="${project.conf.builddir}/deploy" verbose="on" includeemptydirs="on" failonerror="on" /> |
156 | <copy todir="${project.conf.builddir}"> | 147 | <copy todir="${project.conf.builddir}"> |
148 | + <filterchain id="filters"> | ||
149 | + <replacetokens begintoken="@@" endtoken="@@"> | ||
150 | + <token key="package_version" value="${project.conf.version}" /> | ||
151 | + <token key="license" value="${project.conf.license}" /> | ||
152 | + <token key="release_hash" value="${project.conf.hash}" /> | ||
153 | + </replacetokens> | ||
154 | + </filterchain> | ||
157 | <fileset refid="allfiles" /> | 155 | <fileset refid="allfiles" /> |
158 | </copy> | 156 | </copy> |
159 | </target> | 157 | </target> |
@@ -177,9 +175,9 @@ | @@ -177,9 +175,9 @@ | ||
177 | </fileset> | 175 | </fileset> |
178 | </zip> | 176 | </zip> |
179 | </target> | 177 | </target> |
180 | - | 178 | + |
181 | <!-- Cria uma nova release --> | 179 | <!-- Cria uma nova release --> |
182 | - <target name="release" depends="migrate, build, tests, gzip, zip"> | 180 | + <target name="release" depends="migrate, build, gzip, zip"> |
183 | <echo msg="OK! Build construído com sucesso." /> | 181 | <echo msg="OK! Build construído com sucesso." /> |
184 | <php function="memory_get_peak_usage" returnProperty="build.report.memory_peak" /> | 182 | <php function="memory_get_peak_usage" returnProperty="build.report.memory_peak" /> |
185 | <echo msg="Pico de memória: ${build.report.memory_peak}." /> | 183 | <echo msg="Pico de memória: ${build.report.memory_peak}." /> |
ieducar/phpunit.xml
@@ -0,0 +1,55 @@ | @@ -0,0 +1,55 @@ | ||
1 | +<?php | ||
2 | + | ||
3 | +/** | ||
4 | + * i-Educar - Sistema de gestão escolar | ||
5 | + * | ||
6 | + * Copyright (C) 2006 Prefeitura Municipal de Itajaí | ||
7 | + * <ctima@itajai.sc.gov.br> | ||
8 | + * | ||
9 | + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo | ||
10 | + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free | ||
11 | + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) | ||
12 | + * qualquer versão posterior. | ||
13 | + * | ||
14 | + * Este programa é distribuído na expectativa de que seja útil, porém, SEM | ||
15 | + * NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU | ||
16 | + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral | ||
17 | + * do GNU para mais detalhes. | ||
18 | + * | ||
19 | + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto | ||
20 | + * com este programa; se não, escreva para a Free Software Foundation, Inc., no | ||
21 | + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | ||
22 | + * | ||
23 | + * @author Eriksen Costa Paixão <eriksen.paixao_bs@cobra.com.br> | ||
24 | + * @category i-Educar | ||
25 | + * @license @@license@@ | ||
26 | + * @package Tests | ||
27 | + * @since Arquivo disponível desde a versão 1.1.0 | ||
28 | + * @version $Id$ | ||
29 | + */ | ||
30 | + | ||
31 | +require_once 'unit/AllTests.php'; | ||
32 | +require_once 'functional/AllTests.php'; | ||
33 | + | ||
34 | +/** | ||
35 | + * AllTests class. | ||
36 | + * | ||
37 | + * Arquivo de definição de suíte para o projeto. | ||
38 | + * | ||
39 | + * @author Eriksen Costa Paixão <eriksen.paixao_bs@cobra.com.br> | ||
40 | + * @category i-Educar | ||
41 | + * @license @@license@@ | ||
42 | + * @package Tests | ||
43 | + * @since Classe disponível desde a versão 1.1.0 | ||
44 | + * @version @@package_version@@ | ||
45 | + */ | ||
46 | +class AllTests | ||
47 | +{ | ||
48 | + public static function suite() | ||
49 | + { | ||
50 | + $suite = new PHPUnit_Framework_TestSuite('Suíte de testes do projeto (unitários e funcionais)'); | ||
51 | + $suite->addTest(Unit_AllTests::suite()); | ||
52 | + $suite->addTest(Functional_AllTests::suite()); | ||
53 | + return $suite; | ||
54 | + } | ||
55 | +} | ||
0 | \ No newline at end of file | 56 | \ No newline at end of file |
ieducar/tests/FunctionalBaseTest.class.php
1 | <?php | 1 | <?php |
2 | 2 | ||
3 | -/* | 3 | +/** |
4 | * i-Educar - Sistema de gestão escolar | 4 | * i-Educar - Sistema de gestão escolar |
5 | * | 5 | * |
6 | * Copyright (C) 2006 Prefeitura Municipal de Itajaí | 6 | * Copyright (C) 2006 Prefeitura Municipal de Itajaí |
@@ -19,61 +19,65 @@ | @@ -19,61 +19,65 @@ | ||
19 | * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto | 19 | * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto |
20 | * com este programa; se não, escreva para a Free Software Foundation, Inc., no | 20 | * com este programa; se não, escreva para a Free Software Foundation, Inc., no |
21 | * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | 21 | * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. |
22 | + * | ||
23 | + * @author Eriksen Costa Paixão <eriksen.paixao_bs@cobra.com.br> | ||
24 | + * @category i-Educar | ||
25 | + * @license @@license@@ | ||
26 | + * @package FunctionalTests | ||
27 | + * @since Arquivo disponível desde a versão 1.0.1 | ||
28 | + * @version $Id$ | ||
22 | */ | 29 | */ |
23 | 30 | ||
31 | +require_once 'PHPUnit/Extensions/SeleniumTestCase.php'; | ||
32 | + | ||
24 | /** | 33 | /** |
25 | * FunctionBaseTest class. | 34 | * FunctionBaseTest class. |
26 | * | 35 | * |
27 | * Contém as configurações de acesso ao servidor Selenium RC, a conta de usuário | 36 | * Contém as configurações de acesso ao servidor Selenium RC, a conta de usuário |
28 | * a ser utilizada no teste e alguns métodos auxiliares. | 37 | * a ser utilizada no teste e alguns métodos auxiliares. |
29 | * | 38 | * |
30 | - * Muda o diretório atual para que os testes possam ser facilmente invocados | ||
31 | - * em qualquer subdiretório do sistema. | ||
32 | - * | ||
33 | * Abstrai o PHPUnit, diminuindo a dependência de seu uso. Inclui a classe | 39 | * Abstrai o PHPUnit, diminuindo a dependência de seu uso. Inclui a classe |
34 | * de banco de dados para facilitar no tearDown de dados de teste. | 40 | * de banco de dados para facilitar no tearDown de dados de teste. |
35 | * | 41 | * |
36 | - * @author Eriksen Costa Paixão <eriksen.paixao_bs@cobra.com.br> | ||
37 | - * @license http://creativecommons.org/licenses/GPL/2.0/legalcode.pt CC GNU GPL | ||
38 | - * @package Test | ||
39 | - * @since Classe disponível desde a versão 1.0.1 | ||
40 | - * @version $Id$ | 42 | + * @author Eriksen Costa Paixão <eriksen.paixao_bs@cobra.com.br> |
43 | + * @category i-Educar | ||
44 | + * @license http://creativecommons.org/licenses/GPL/2.0/legalcode.pt CC GNU GPL | ||
45 | + * @package FunctionalTests | ||
46 | + * @since Classe disponível desde a versão 1.0.1 | ||
47 | + * @version @@package_version@@ | ||
41 | */ | 48 | */ |
42 | - | ||
43 | -chdir(realpath(dirname(__FILE__) . '/../') . '/intranet'); | ||
44 | -require_once 'PHPUnit/Extensions/SeleniumTestCase.php'; | ||
45 | -require_once 'include/clsBanco.inc.php'; | ||
46 | - | ||
47 | -abstract class FunctionalBaseTest extends PHPUnit_Extensions_SeleniumTestCase { | ||
48 | - | ||
49 | - // Configurações do Selenium RC | 49 | +abstract class FunctionalBaseTest extends PHPUnit_Extensions_SeleniumTestCase |
50 | +{ | ||
51 | + // Configurações do Selenium RC. | ||
50 | static protected | 52 | static protected |
51 | $slBrowserUrl = 'http://ieducar.local', | 53 | $slBrowserUrl = 'http://ieducar.local', |
52 | $slBrowser = '*firefox', | 54 | $slBrowser = '*firefox', |
53 | $slPort = 4444, | 55 | $slPort = 4444, |
54 | $slHost = 'localhost'; | 56 | $slHost = 'localhost'; |
55 | 57 | ||
56 | - // Conta de usuário para testes funcionais | 58 | + // Conta de usuário para testes funcionais. |
57 | protected | 59 | protected |
58 | $slUsuarioLogin = 'admin', | 60 | $slUsuarioLogin = 'admin', |
59 | $slUsuarioSenha = 'admin'; | 61 | $slUsuarioSenha = 'admin'; |
60 | 62 | ||
61 | - protected function setUp() { | 63 | + protected function setUp() |
64 | + { | ||
62 | $this->setBrowser(self::$slBrowser); | 65 | $this->setBrowser(self::$slBrowser); |
63 | $this->setHost(self::$slHost); | 66 | $this->setHost(self::$slHost); |
64 | $this->setPort(self::$slPort); | 67 | $this->setPort(self::$slPort); |
65 | $this->setBrowserUrl(self::$slBrowserUrl); | 68 | $this->setBrowserUrl(self::$slBrowserUrl); |
66 | } | 69 | } |
67 | 70 | ||
68 | - protected function doLogin() { | 71 | + protected function doLogin() |
72 | + { | ||
69 | $this->open('/intranet'); | 73 | $this->open('/intranet'); |
70 | $this->type('login', $this->slUsuarioLogin); | 74 | $this->type('login', $this->slUsuarioLogin); |
71 | $this->type('senha', $this->slUsuarioSenha); | 75 | $this->type('senha', $this->slUsuarioSenha); |
72 | $this->clickAndWait("//input[@value='Entrar']"); | 76 | $this->clickAndWait("//input[@value='Entrar']"); |
73 | } | 77 | } |
74 | 78 | ||
75 | - protected function doLogout() { | 79 | + protected function doLogout() |
80 | + { | ||
76 | $this->click("//img[@alt='Logout']"); | 81 | $this->click("//img[@alt='Logout']"); |
77 | } | 82 | } |
78 | - | ||
79 | -} | 83 | +} |
80 | \ No newline at end of file | 84 | \ No newline at end of file |
@@ -0,0 +1,201 @@ | @@ -0,0 +1,201 @@ | ||
1 | +<?php | ||
2 | + | ||
3 | +/** | ||
4 | + * i-Educar - Sistema de gestão escolar | ||
5 | + * | ||
6 | + * Copyright (C) 2006 Prefeitura Municipal de Itajaí | ||
7 | + * <ctima@itajai.sc.gov.br> | ||
8 | + * | ||
9 | + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo | ||
10 | + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free | ||
11 | + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) | ||
12 | + * qualquer versão posterior. | ||
13 | + * | ||
14 | + * Este programa é distribuído na expectativa de que seja útil, porém, SEM | ||
15 | + * NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU | ||
16 | + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral | ||
17 | + * do GNU para mais detalhes. | ||
18 | + * | ||
19 | + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto | ||
20 | + * com este programa; se não, escreva para a Free Software Foundation, Inc., no | ||
21 | + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | ||
22 | + * | ||
23 | + * @author Eriksen Costa Paixão <eriksen.paixao_bs@cobra.com.br> | ||
24 | + * @category i-Educar | ||
25 | + * @license @@license@@ | ||
26 | + * @package Tests | ||
27 | + * @since Arquivo disponível desde a versão 1.1.0 | ||
28 | + * @version $Id$ | ||
29 | + */ | ||
30 | + | ||
31 | +require_once 'PHPUnit/Framework.php'; | ||
32 | +require_once 'PHPUnit/Runner/IncludePathTestCollector.php'; | ||
33 | + | ||
34 | +/** | ||
35 | + * TestCollector abstract class. | ||
36 | + * | ||
37 | + * Classe abstrata que provê um ponto de extensão para classes de definição de | ||
38 | + * suíte de testes do PHPUnit (veja {@link Orga}) | ||
39 | + * | ||
40 | + * Ao estender corretamente essa classe, todos as classes de teste do diretório | ||
41 | + * da classe de definição de suíte de testes serão adicionados à suíte, | ||
42 | + * tornando desnecessário a nessidade de usar os construtores de linguagem | ||
43 | + * require e include para incluir esses arquivos. | ||
44 | + * | ||
45 | + * Para estender essa classe, basta informar o caminho para o arquivo da classe | ||
46 | + * de definição da suíte na variável protegida $_file, exemplo: | ||
47 | + * | ||
48 | + * <code> | ||
49 | + * class App_Model_AllTests extends TestCollector | ||
50 | + * { | ||
51 | + * protected $_file = __FILE__; | ||
52 | + * } | ||
53 | + * </code> | ||
54 | + * | ||
55 | + * Isso é o suficiente para conseguir coletar todos os arquivos do diretório. | ||
56 | + * Para criar uma suíte de testes com todas as classes de teste do diretório, | ||
57 | + * basta criar uma instância da classe e chamar o método addDirectoryTests(): | ||
58 | + * | ||
59 | + * <code> | ||
60 | + * public static function suite() | ||
61 | + * { | ||
62 | + * $instance = new self(); | ||
63 | + * return $instance->createTestSuite('App_Model: testes unitários') | ||
64 | + * ->addDirectoryTests(); | ||
65 | + * } | ||
66 | + * </code> | ||
67 | + * | ||
68 | + * Se a variável de instância $_name estiver sobrescrita, ela será utilizada | ||
69 | + * por padrão caso o método createTestSuite() seja chamado sem o parâmetro nome. | ||
70 | + * Dessa forma, basta chamar o método addDirectoryTests(): | ||
71 | + * | ||
72 | + * <code> | ||
73 | + * protected $_name = 'App_model: testes unitários'; | ||
74 | + * | ||
75 | + * public static function suite() | ||
76 | + * { | ||
77 | + * $instance = new self(); | ||
78 | + * return $instance->addDirectoryTests(); | ||
79 | + * } | ||
80 | + * </code> | ||
81 | + * | ||
82 | + * @author Eriksen Costa Paixão <eriksen.paixao_bs@cobra.com.br> | ||
83 | + * @category i-Educar | ||
84 | + * @license @@license@@ | ||
85 | + * @package Tests | ||
86 | + * @since Classe disponível desde a versão 1.1.0 | ||
87 | + * @version @@package_version@@ | ||
88 | + */ | ||
89 | +abstract class TestCollector | ||
90 | +{ | ||
91 | + /** | ||
92 | + * Caminho completo do arquivo da classe que estende TestCollector. | ||
93 | + * @var string | ||
94 | + */ | ||
95 | + protected $_file = NULL; | ||
96 | + | ||
97 | + /** | ||
98 | + * Diretório onde residem os arquivos com as classes de teste. | ||
99 | + * @var string | ||
100 | + */ | ||
101 | + protected $_dir = NULL; | ||
102 | + | ||
103 | + /** | ||
104 | + * Nome da suíte de testes. | ||
105 | + * @var string | ||
106 | + */ | ||
107 | + protected $_name = ''; | ||
108 | + | ||
109 | + /** | ||
110 | + * Uma instância de PHPUnit_Framework_TestSuite. | ||
111 | + * @var PHPUnit_Framework_TestSuite | ||
112 | + */ | ||
113 | + protected $_suite = NULL; | ||
114 | + | ||
115 | + /** | ||
116 | + * Construtor. | ||
117 | + * @return TestCollector | ||
118 | + */ | ||
119 | + public function __construct() | ||
120 | + { | ||
121 | + $this->_defineCurrentDir(); | ||
122 | + } | ||
123 | + | ||
124 | + /** | ||
125 | + * Cria um objeto PHPUnit_Framework_TestSuite com o nome passado como | ||
126 | + * argumento ou usando a variável de instância $_name. | ||
127 | + * | ||
128 | + * @param string $name O nome para a suíte de testes | ||
129 | + * @return TestCollector Interface fluída | ||
130 | + * @throws InvalidArgumentException | ||
131 | + */ | ||
132 | + public function createTestSuite($name = '') | ||
133 | + { | ||
134 | + if ((trim((string) $name)) == '' && $this->_name == '') { | ||
135 | + throw new InvalidArgumentException('A classe concreta deve sobrescrever a ' | ||
136 | + . 'variável "$_name" ou passar um nome válido ao chamar o método' | ||
137 | + . 'createTestSuite().'); | ||
138 | + } | ||
139 | + if (trim((string) $name) != '') { | ||
140 | + $name = $this->_name; | ||
141 | + } | ||
142 | + | ||
143 | + $this->_suite = new PHPUnit_Framework_TestSuite($name); | ||
144 | + return $this; | ||
145 | + } | ||
146 | + | ||
147 | + /** | ||
148 | + * Adiciona os testes do diretório da classe de definição de suíte. | ||
149 | + * | ||
150 | + * @param PHPUnit_Framework_TestSuite $suite | ||
151 | + * @return PHPUnit_Framework_TestSuite | ||
152 | + */ | ||
153 | + public function addDirectoryTests(PHPUnit_Framework_TestSuite $suite = NULL) | ||
154 | + { | ||
155 | + // Se não existir um objeto PHPUnit_Framework_TestSuite, cria um com o nome | ||
156 | + // do arquivo da classe de definição da suíte | ||
157 | + if ($this->_suite == NULL && $suite == NULL) { | ||
158 | + $this->createTestSuite(); | ||
159 | + } | ||
160 | + if ($suite == NULL) { | ||
161 | + $suite = $this->_suite; | ||
162 | + } | ||
163 | + | ||
164 | + $suite->addTestFiles($this->_collectTests()); | ||
165 | + return $suite; | ||
166 | + } | ||
167 | + | ||
168 | + /** | ||
169 | + * Retorna um PHPUnit_Util_FilterIterator que contém as regras de inclusão | ||
170 | + * de testes do diretório definido por $_fir. | ||
171 | + * | ||
172 | + * @return PHPUnit_Util_FilterIterator | ||
173 | + */ | ||
174 | + protected function _collectTests() | ||
175 | + { | ||
176 | + $testCollector = new PHPUnit_Runner_IncludePathTestCollector(array($this->_dir)); | ||
177 | + return $testCollector->collectTests(); | ||
178 | + } | ||
179 | + | ||
180 | + /** | ||
181 | + * Define o diretório atual da classe que estende TestCollector. O diretório é | ||
182 | + * definido pela variável de instância $_file. | ||
183 | + * | ||
184 | + * @throws Exception Lança exceção | ||
185 | + * @todo Refatorar o código para utilizar {@link http://php.net/lsb Late static binding} | ||
186 | + * quando a versão do PHP for a 5.3. | ||
187 | + */ | ||
188 | + protected function _defineCurrentDir() | ||
189 | + { | ||
190 | + if ($this->_file === NULL) { | ||
191 | + throw new Exception('A classe concreta deve sobrescrever a variável "$_file".'); | ||
192 | + } | ||
193 | + if ($this->_dir == '') { | ||
194 | + $dir = realpath(dirname($this->_file)); | ||
195 | + if (!is_dir($dir)) { | ||
196 | + throw new Exception('The path "'. $dir .'" is not a valid directory'); | ||
197 | + } | ||
198 | + $this->_dir = $dir; | ||
199 | + } | ||
200 | + } | ||
201 | +} | ||
0 | \ No newline at end of file | 202 | \ No newline at end of file |
ieducar/tests/UnitBaseTest.class.php
1 | <?php | 1 | <?php |
2 | 2 | ||
3 | -/* | 3 | +/** |
4 | * i-Educar - Sistema de gestão escolar | 4 | * i-Educar - Sistema de gestão escolar |
5 | * | 5 | * |
6 | * Copyright (C) 2006 Prefeitura Municipal de Itajaí | 6 | * Copyright (C) 2006 Prefeitura Municipal de Itajaí |
@@ -19,33 +19,27 @@ | @@ -19,33 +19,27 @@ | ||
19 | * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto | 19 | * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto |
20 | * com este programa; se não, escreva para a Free Software Foundation, Inc., no | 20 | * com este programa; se não, escreva para a Free Software Foundation, Inc., no |
21 | * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | 21 | * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. |
22 | + * | ||
23 | + * @author Eriksen Costa Paixão <eriksen.paixao_bs@cobra.com.br> | ||
24 | + * @category i-Educar | ||
25 | + * @license @@license@@ | ||
26 | + * @package UnitTests | ||
27 | + * @since Arquivo disponível desde a versão 1.0.1 | ||
28 | + * @version $Id$ | ||
22 | */ | 29 | */ |
23 | 30 | ||
24 | - | ||
25 | -/* | ||
26 | - * Faz require do bootstrap para que as mesmas configurações do ambiente | ||
27 | - * (conexão com o banco de dados, títulos, configurações do PHP), sejam | ||
28 | - * utilizadas pelos unit test para evitar discrepâncias no comportamento. | ||
29 | - */ | ||
30 | -require_once realpath(dirname(__FILE__) . '/../') . '/includes/bootstrap.php'; | ||
31 | - | ||
32 | -chdir(realpath(dirname(__FILE__) . '/../') . '/intranet'); | ||
33 | -require_once 'PHPUnit/Framework.php'; | ||
34 | -require_once 'include/clsBanco.inc.php'; | ||
35 | - | ||
36 | - | ||
37 | /** | 31 | /** |
38 | * UnitBaseTest abstract class. | 32 | * UnitBaseTest abstract class. |
39 | * | 33 | * |
40 | - * Muda o diretório atual para que os testes possam ser facilmente invocados | ||
41 | - * em qualquer subdiretório do sistema. | ||
42 | - * | ||
43 | * Abstrai o PHPUnit, diminuindo a dependência de seu uso. | 34 | * Abstrai o PHPUnit, diminuindo a dependência de seu uso. |
44 | * | 35 | * |
45 | - * @author Eriksen Costa Paixão <eriksen.paixao_bs@cobra.com.br> | ||
46 | - * @license http://creativecommons.org/licenses/GPL/2.0/legalcode.pt CC GNU GPL | ||
47 | - * @package Test | ||
48 | - * @since Classe disponível desde a versão 1.0.1 | ||
49 | - * @version $Id$ | 36 | + * @author Eriksen Costa Paixão <eriksen.paixao_bs@cobra.com.br> |
37 | + * @category i-Educar | ||
38 | + * @license @@license@@ | ||
39 | + * @package UnitTests | ||
40 | + * @since Classe disponível desde a versão 1.0.1 | ||
41 | + * @version @@package_version@@ | ||
50 | */ | 42 | */ |
51 | -abstract class UnitBaseTest extends PHPUnit_Framework_TestCase {} | ||
52 | \ No newline at end of file | 43 | \ No newline at end of file |
44 | +abstract class UnitBaseTest extends PHPUnit_Framework_TestCase | ||
45 | +{ | ||
46 | +} | ||
53 | \ No newline at end of file | 47 | \ No newline at end of file |
@@ -0,0 +1,60 @@ | @@ -0,0 +1,60 @@ | ||
1 | +<?php | ||
2 | + | ||
3 | +/** | ||
4 | + * i-Educar - Sistema de gestão escolar | ||
5 | + * | ||
6 | + * Copyright (C) 2006 Prefeitura Municipal de Itajaí | ||
7 | + * <ctima@itajai.sc.gov.br> | ||
8 | + * | ||
9 | + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo | ||
10 | + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free | ||
11 | + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) | ||
12 | + * qualquer versão posterior. | ||
13 | + * | ||
14 | + * Este programa é distribuído na expectativa de que seja útil, porém, SEM | ||
15 | + * NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU | ||
16 | + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral | ||
17 | + * do GNU para mais detalhes. | ||
18 | + * | ||
19 | + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto | ||
20 | + * com este programa; se não, escreva para a Free Software Foundation, Inc., no | ||
21 | + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | ||
22 | + * | ||
23 | + * @author Eriksen Costa Paixão <eriksen.paixao_bs@cobra.com.br> | ||
24 | + * @category i-Educar | ||
25 | + * @license @@license@@ | ||
26 | + * @package Tests | ||
27 | + * @since Arquivo disponível desde a versão 1.1.0 | ||
28 | + * @version $Id$ | ||
29 | + */ | ||
30 | + | ||
31 | +/** | ||
32 | + * Arquivo de bootstrap para os testes do projeto. Configura o include_path e | ||
33 | + * inclui alguns arquivos necessários nos testes unitários e funcionais. | ||
34 | + */ | ||
35 | + | ||
36 | + | ||
37 | +// Diretório raiz do projeto. | ||
38 | +$root = realpath(dirname(__FILE__) . '/../'); | ||
39 | + | ||
40 | +// Adiciona os diretórios tests/unit, tests/functional, tests/, ./ e intranet/ | ||
41 | +// ao include_path. | ||
42 | +$paths = array(); | ||
43 | +$paths[] = join(DIRECTORY_SEPARATOR, array($root, 'tests', 'unit')); | ||
44 | +$paths[] = join(DIRECTORY_SEPARATOR, array($root, 'tests', 'functional')); | ||
45 | +$paths[] = join(DIRECTORY_SEPARATOR, array($root, 'tests')); | ||
46 | +$paths[] = join(DIRECTORY_SEPARATOR, array($root, '.')); | ||
47 | +$paths[] = join(DIRECTORY_SEPARATOR, array($root, 'intranet')); | ||
48 | + | ||
49 | +// Configura o include_path. | ||
50 | +set_include_path(join(PATH_SEPARATOR, $paths) . PATH_SEPARATOR . get_include_path()); | ||
51 | + | ||
52 | +// Arquivos em intranet/ usam includes com caminho relativo, muda diretório | ||
53 | +// atual para evitar warnings e errors. | ||
54 | +chdir($root . '/intranet'); | ||
55 | +unset($root, $paths); | ||
56 | + | ||
57 | +require_once 'TestCollector.php'; | ||
58 | +require_once 'UnitBaseTest.class.php'; | ||
59 | +require_once 'FunctionalBaseTest.class.php'; | ||
60 | +require_once 'include/clsBanco.inc.php'; | ||
0 | \ No newline at end of file | 61 | \ No newline at end of file |
@@ -0,0 +1,53 @@ | @@ -0,0 +1,53 @@ | ||
1 | +<?php | ||
2 | + | ||
3 | +/** | ||
4 | + * i-Educar - Sistema de gestão escolar | ||
5 | + * | ||
6 | + * Copyright (C) 2006 Prefeitura Municipal de Itajaí | ||
7 | + * <ctima@itajai.sc.gov.br> | ||
8 | + * | ||
9 | + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo | ||
10 | + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free | ||
11 | + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) | ||
12 | + * qualquer versão posterior. | ||
13 | + * | ||
14 | + * Este programa é distribuído na expectativa de que seja útil, porém, SEM | ||
15 | + * NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU | ||
16 | + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral | ||
17 | + * do GNU para mais detalhes. | ||
18 | + * | ||
19 | + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto | ||
20 | + * com este programa; se não, escreva para a Free Software Foundation, Inc., no | ||
21 | + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | ||
22 | + * | ||
23 | + * @author Eriksen Costa Paixão <eriksen.paixao_bs@cobra.com.br> | ||
24 | + * @category i-Educar | ||
25 | + * @license @@license@@ | ||
26 | + * @package FunctionalTests | ||
27 | + * @since Arquivo disponível desde a versão 1.1.0 | ||
28 | + * @version $Id$ | ||
29 | + */ | ||
30 | + | ||
31 | +/** | ||
32 | + * Functionl_AllTests class. | ||
33 | + * | ||
34 | + * Arquivo de definição de suíte de testes funcionais. | ||
35 | + * | ||
36 | + * @author Eriksen Costa Paixão <eriksen.paixao_bs@cobra.com.br> | ||
37 | + * @category i-Educar | ||
38 | + * @license @@license@@ | ||
39 | + * @package FunctionalTests | ||
40 | + * @since Classe disponível desde a versão 1.1.0 | ||
41 | + * @version @@package_version@@ | ||
42 | + */ | ||
43 | +class Functional_AllTests extends TestCollector | ||
44 | +{ | ||
45 | + protected $_name = 'Suíte de testes funcionais do projeto'; | ||
46 | + protected $_file = __FILE__; | ||
47 | + | ||
48 | + public static function suite() | ||
49 | + { | ||
50 | + $instance = new self; | ||
51 | + return $instance->addDirectoryTests(); | ||
52 | + } | ||
53 | +} | ||
0 | \ No newline at end of file | 54 | \ No newline at end of file |
ieducar/tests/functional/ServidorCategoriaNivelWebTest.class.php
@@ -1,75 +0,0 @@ | @@ -1,75 +0,0 @@ | ||
1 | -<?php | ||
2 | - | ||
3 | -/* | ||
4 | - * i-Educar - Sistema de gestão escolar | ||
5 | - * | ||
6 | - * Copyright (C) 2006 Prefeitura Municipal de Itajaí | ||
7 | - * <ctima@itajai.sc.gov.br> | ||
8 | - * | ||
9 | - * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo | ||
10 | - * sob os termos da Licença Pública Geral GNU conforme publicada pela Free | ||
11 | - * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) | ||
12 | - * qualquer versão posterior. | ||
13 | - * | ||
14 | - * Este programa é distribuído na expectativa de que seja útil, porém, SEM | ||
15 | - * NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU | ||
16 | - * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral | ||
17 | - * do GNU para mais detalhes. | ||
18 | - * | ||
19 | - * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto | ||
20 | - * com este programa; se não, escreva para a Free Software Foundation, Inc., no | ||
21 | - * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | ||
22 | - */ | ||
23 | - | ||
24 | -/** | ||
25 | - * ServidorCategoriaNivelWebTest class. | ||
26 | - * | ||
27 | - * Testa as ações de atualizar um nível de categoria, como verificação | ||
28 | - * da correção do bug #21. | ||
29 | - * | ||
30 | - * Esse teste precisa ser executado com o banco de dados distribuído na | ||
31 | - * versão 1.0.0. | ||
32 | - * | ||
33 | - * @author Eriksen Costa Paixão <eriksen.paixao_bs@cobra.com.br> | ||
34 | - * @license http://creativecommons.org/licenses/GPL/2.0/legalcode.pt CC GNU GPL | ||
35 | - * @package Test | ||
36 | - * @subpackage FunctionalTest | ||
37 | - * @since Classe disponível desde a versão 1.0.1 | ||
38 | - * @version $Id$ | ||
39 | - */ | ||
40 | - | ||
41 | -require_once realpath(dirname(__FILE__) . '/../') . '/FunctionalBaseTest.class.php'; | ||
42 | - | ||
43 | -class ServidorCategoriaNivelWebTest extends FunctionalBaseTest { | ||
44 | - | ||
45 | - private $slStringTest = 'Selenese Nivel Teste'; | ||
46 | - | ||
47 | - protected function tearDown() { | ||
48 | - require_once 'include/pmieducar/clsPmieducarCategoriaNivel.inc.php'; | ||
49 | - | ||
50 | - $db = new clsBanco(); | ||
51 | - $categoriaNivel = new clsPmieducarCategoriaNivel(); | ||
52 | - $sql = sprintf('DELETE FROM %s WHERE %s = \'%s\'', | ||
53 | - $categoriaNivel->_tabela, 'nm_categoria_nivel', $this->slStringTest); | ||
54 | - | ||
55 | - $db->Consulta($sql); | ||
56 | - } | ||
57 | - | ||
58 | - private function createNewEntry() { | ||
59 | - $this->open("/intranet/educar_categoria_nivel_lst.php"); | ||
60 | - $this->clickAndWait("//input[@value=' Novo ']"); | ||
61 | - $this->type("nm_categoria_nivel", $this->slStringTest); | ||
62 | - $this->clickAndWait("btn_enviar"); | ||
63 | - } | ||
64 | - | ||
65 | - public function testCategoriaNivelDelete() { | ||
66 | - $this->doLogin(); | ||
67 | - $this->createNewEntry(); | ||
68 | - | ||
69 | - $this->clickAndWait("link=" . $this->slStringTest); | ||
70 | - $this->clickAndWait("//input[@value=' Editar ']"); | ||
71 | - $this->clickAndWait("//input[@value=' Excluir ']"); | ||
72 | - $this->assertTrue((bool) preg_match('/^Excluir registro[\s\S]$/', $this->getConfirmation())); | ||
73 | - $this->assertTrue(!$this->isTextPresent($this->slStringTest)); | ||
74 | - } | ||
75 | -} | ||
76 | \ No newline at end of file | 0 | \ No newline at end of file |
ieducar/tests/functional/ServidorCategoriaNivelWebTest.php
0 → 100644
@@ -0,0 +1,83 @@ | @@ -0,0 +1,83 @@ | ||
1 | +<?php | ||
2 | + | ||
3 | +/* | ||
4 | + * i-Educar - Sistema de gestão escolar | ||
5 | + * | ||
6 | + * Copyright (C) 2006 Prefeitura Municipal de Itajaí | ||
7 | + * <ctima@itajai.sc.gov.br> | ||
8 | + * | ||
9 | + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo | ||
10 | + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free | ||
11 | + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) | ||
12 | + * qualquer versão posterior. | ||
13 | + * | ||
14 | + * Este programa é distribuído na expectativa de que seja útil, porém, SEM | ||
15 | + * NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU | ||
16 | + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral | ||
17 | + * do GNU para mais detalhes. | ||
18 | + * | ||
19 | + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto | ||
20 | + * com este programa; se não, escreva para a Free Software Foundation, Inc., no | ||
21 | + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | ||
22 | + * | ||
23 | + * @author Eriksen Costa Paixão <eriksen.paixao_bs@cobra.com.br> | ||
24 | + * @category i-Educar | ||
25 | + * @license @@license@@ | ||
26 | + * @package FunctionalTests | ||
27 | + * @since Arquivo disponível desde a versão 1.0.1 | ||
28 | + * @version $Id$ | ||
29 | + */ | ||
30 | + | ||
31 | +require_once 'include/pmieducar/clsPmieducarCategoriaNivel.inc.php'; | ||
32 | + | ||
33 | +/** | ||
34 | + * ServidorCategoriaNivelWebTest class. | ||
35 | + * | ||
36 | + * Testa as ações de atualizar um nível de categoria, como verificação | ||
37 | + * da correção do bug #21. | ||
38 | + * | ||
39 | + * Esse teste precisa ser executado com o banco de dados distribuído na | ||
40 | + * versão 1.0.0. | ||
41 | + * | ||
42 | + * @author Eriksen Costa Paixão <eriksen.paixao_bs@cobra.com.br> | ||
43 | + * @category i-Educar | ||
44 | + * @license @@license@@ | ||
45 | + * @link http://svn.softwarepublico.gov.br/trac/ieducar/ticket/21 | ||
46 | + * @package FunctionalTests | ||
47 | + * @since Classe disponível desde a versão 1.0.1 | ||
48 | + * @version @@package_version@@ | ||
49 | + */ | ||
50 | +class ServidorCategoriaNivelWebTest extends FunctionalBaseTest | ||
51 | +{ | ||
52 | + private $slStringTest = 'Selenese Nivel Teste'; | ||
53 | + | ||
54 | + protected function tearDown() | ||
55 | + { | ||
56 | + $db = new clsBanco(); | ||
57 | + $categoriaNivel = new clsPmieducarCategoriaNivel(); | ||
58 | + $sql = sprintf('DELETE FROM %s WHERE %s = \'%s\'', | ||
59 | + $categoriaNivel->_tabela, 'nm_categoria_nivel', $this->slStringTest); | ||
60 | + | ||
61 | + $db->Consulta($sql); | ||
62 | + } | ||
63 | + | ||
64 | + private function createNewEntry() | ||
65 | + { | ||
66 | + $this->open("/intranet/educar_categoria_nivel_lst.php"); | ||
67 | + $this->clickAndWait("//input[@value=' Novo ']"); | ||
68 | + $this->type("nm_categoria_nivel", $this->slStringTest); | ||
69 | + $this->clickAndWait("btn_enviar"); | ||
70 | + } | ||
71 | + | ||
72 | + public function testCategoriaNivelDelete() | ||
73 | + { | ||
74 | + $this->doLogin(); | ||
75 | + $this->createNewEntry(); | ||
76 | + | ||
77 | + $this->clickAndWait("link=" . $this->slStringTest); | ||
78 | + $this->clickAndWait("//input[@value=' Editar ']"); | ||
79 | + $this->clickAndWait("//input[@value=' Excluir ']"); | ||
80 | + $this->assertTrue((bool) preg_match('/^Excluir registro[\s\S]$/', $this->getConfirmation())); | ||
81 | + $this->assertTrue(!$this->isTextPresent($this->slStringTest)); | ||
82 | + } | ||
83 | +} | ||
0 | \ No newline at end of file | 84 | \ No newline at end of file |
ieducar/tests/functional/ServidorMotivoAfastamentoWebTest.class.php
@@ -1,89 +0,0 @@ | @@ -1,89 +0,0 @@ | ||
1 | -<?php | ||
2 | - | ||
3 | -/* | ||
4 | - * i-Educar - Sistema de gestão escolar | ||
5 | - * | ||
6 | - * Copyright (C) 2006 Prefeitura Municipal de Itajaí | ||
7 | - * <ctima@itajai.sc.gov.br> | ||
8 | - * | ||
9 | - * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo | ||
10 | - * sob os termos da Licença Pública Geral GNU conforme publicada pela Free | ||
11 | - * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) | ||
12 | - * qualquer versão posterior. | ||
13 | - * | ||
14 | - * Este programa é distribuído na expectativa de que seja útil, porém, SEM | ||
15 | - * NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU | ||
16 | - * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral | ||
17 | - * do GNU para mais detalhes. | ||
18 | - * | ||
19 | - * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto | ||
20 | - * com este programa; se não, escreva para a Free Software Foundation, Inc., no | ||
21 | - * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | ||
22 | - */ | ||
23 | - | ||
24 | -/** | ||
25 | - * ServidorMotivoAfastamentoWebTest class. | ||
26 | - * | ||
27 | - * Testa as ações de atualizar e apagar um motivo de afastamento, como | ||
28 | - * verificação da correção do bug #20. | ||
29 | - * | ||
30 | - * Esse teste precisa ser executado com o banco de dados distribuído na | ||
31 | - * versão 1.0.0. | ||
32 | - * | ||
33 | - * @author Eriksen Costa Paixão <eriksen.paixao_bs@cobra.com.br> | ||
34 | - * @license http://creativecommons.org/licenses/GPL/2.0/legalcode.pt CC GNU GPL | ||
35 | - * @package Test | ||
36 | - * @since Classe disponível desde a versão 1.0.1 | ||
37 | - * @version $Id$ | ||
38 | - */ | ||
39 | - | ||
40 | -require_once realpath(dirname(__FILE__) . '/../') . '/FunctionalBaseTest.class.php'; | ||
41 | - | ||
42 | -class ServidorMotivoAfastamentoWebTest extends FunctionalBaseTest { | ||
43 | - | ||
44 | - /** | ||
45 | - * Os testes a seguir cobrem o bug report #20. | ||
46 | - * | ||
47 | - * @link http://svn.softwarepublico.gov.br/trac/ieducar/ticket/20 Bug report #20 | ||
48 | - * @{ | ||
49 | - */ | ||
50 | - public function createNewEntry() { | ||
51 | - $this->open("/intranet/educar_motivo_afastamento_lst.php"); | ||
52 | - $this->clickAndWait("//input[@value=' Novo ']"); | ||
53 | - $this->select("ref_cod_instituicao", "label=i-Educar"); | ||
54 | - $this->type("nm_motivo", "Motivo teste"); | ||
55 | - $this->clickAndWait("btn_enviar"); | ||
56 | - } | ||
57 | - | ||
58 | - public function testMotivoAfastamentoUpdate() { | ||
59 | - $this->doLogin(); | ||
60 | - $this->createNewEntry(); | ||
61 | - | ||
62 | - $this->open("/intranet/educar_motivo_afastamento_cad.php?cod_motivo_afastamento=1"); | ||
63 | - $this->select("ref_cod_instituicao", "label=i-Educar"); | ||
64 | - $this->type("nm_motivo", "Motivo teste"); | ||
65 | - $this->clickAndWait("btn_enviar"); | ||
66 | - | ||
67 | - $statusMessage = $this->isTextPresent("Edição não realizada."); | ||
68 | - $this->assertTrue(!$statusMessage); | ||
69 | - $this->doLogout(); | ||
70 | - } | ||
71 | - | ||
72 | - public function testMotivoAfastamentoDelete() { | ||
73 | - $this->doLogin(); | ||
74 | - | ||
75 | - $this->open("/intranet/educar_motivo_afastamento_lst.php"); | ||
76 | - $this->clickAndWait("link=Motivo teste"); | ||
77 | - $this->clickAndWait("//input[@value=' Editar ']"); | ||
78 | - $this->clickAndWait("//input[@value=' Excluir ']"); | ||
79 | - $this->assertTrue((bool)preg_match('/^Excluir registro[\s\S]$/',$this->getConfirmation())); | ||
80 | - $statusMessage = $this->isTextPresent("Exclusão não realizada."); | ||
81 | - $this->assertTrue(!$statusMessage); | ||
82 | - | ||
83 | - $this->doLogout(); | ||
84 | - } | ||
85 | - /** | ||
86 | - * }@ | ||
87 | - */ | ||
88 | - | ||
89 | -} |
ieducar/tests/functional/ServidorMotivoAfastamentoWebTest.php
0 → 100644
@@ -0,0 +1,88 @@ | @@ -0,0 +1,88 @@ | ||
1 | +<?php | ||
2 | + | ||
3 | +/* | ||
4 | + * i-Educar - Sistema de gestão escolar | ||
5 | + * | ||
6 | + * Copyright (C) 2006 Prefeitura Municipal de Itajaí | ||
7 | + * <ctima@itajai.sc.gov.br> | ||
8 | + * | ||
9 | + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo | ||
10 | + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free | ||
11 | + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) | ||
12 | + * qualquer versão posterior. | ||
13 | + * | ||
14 | + * Este programa é distribuído na expectativa de que seja útil, porém, SEM | ||
15 | + * NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU | ||
16 | + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral | ||
17 | + * do GNU para mais detalhes. | ||
18 | + * | ||
19 | + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto | ||
20 | + * com este programa; se não, escreva para a Free Software Foundation, Inc., no | ||
21 | + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | ||
22 | + * | ||
23 | + * @author Eriksen Costa Paixão <eriksen.paixao_bs@cobra.com.br> | ||
24 | + * @category i-Educar | ||
25 | + * @license @@license@@ | ||
26 | + * @package FunctionalTests | ||
27 | + * @since Classe disponível desde a versão 1.0.1 | ||
28 | + * @version $Id$ | ||
29 | + */ | ||
30 | + | ||
31 | +/** | ||
32 | + * ServidorMotivoAfastamentoWebTest class. | ||
33 | + * | ||
34 | + * Testa as ações de atualizar e apagar um motivo de afastamento, como | ||
35 | + * verificação da correção do bug #20. | ||
36 | + * | ||
37 | + * Esse teste precisa ser executado com o banco de dados distribuído na | ||
38 | + * versão 1.0.0. | ||
39 | + * | ||
40 | + * @author Eriksen Costa Paixão <eriksen.paixao_bs@cobra.com.br> | ||
41 | + * @category i-Educar | ||
42 | + * @license @@license@@ | ||
43 | + * @link http://svn.softwarepublico.gov.br/trac/ieducar/ticket/20 | ||
44 | + * @package FunctionalTests | ||
45 | + * @since Classe disponível desde a versão 1.0.1 | ||
46 | + * @version @@package_version@@ | ||
47 | + */ | ||
48 | +class ServidorMotivoAfastamentoWebTest extends FunctionalBaseTest | ||
49 | +{ | ||
50 | + public function createNewEntry() | ||
51 | + { | ||
52 | + $this->open("/intranet/educar_motivo_afastamento_lst.php"); | ||
53 | + $this->clickAndWait("//input[@value=' Novo ']"); | ||
54 | + $this->select("ref_cod_instituicao", "label=i-Educar"); | ||
55 | + $this->type("nm_motivo", "Motivo teste"); | ||
56 | + $this->clickAndWait("btn_enviar"); | ||
57 | + } | ||
58 | + | ||
59 | + public function testMotivoAfastamentoUpdate() | ||
60 | + { | ||
61 | + $this->doLogin(); | ||
62 | + $this->createNewEntry(); | ||
63 | + | ||
64 | + $this->open("/intranet/educar_motivo_afastamento_cad.php?cod_motivo_afastamento=1"); | ||
65 | + $this->select("ref_cod_instituicao", "label=i-Educar"); | ||
66 | + $this->type("nm_motivo", "Motivo teste"); | ||
67 | + $this->clickAndWait("btn_enviar"); | ||
68 | + | ||
69 | + $statusMessage = $this->isTextPresent("Edição não realizada."); | ||
70 | + $this->assertTrue(!$statusMessage); | ||
71 | + $this->doLogout(); | ||
72 | + } | ||
73 | + | ||
74 | + public function testMotivoAfastamentoDelete() | ||
75 | + { | ||
76 | + $this->doLogin(); | ||
77 | + | ||
78 | + $this->open("/intranet/educar_motivo_afastamento_lst.php"); | ||
79 | + $this->clickAndWait("link=Motivo teste"); | ||
80 | + $this->clickAndWait("//input[@value=' Editar ']"); | ||
81 | + $this->clickAndWait("//input[@value=' Excluir ']"); | ||
82 | + $this->assertTrue((bool)preg_match('/^Excluir registro[\s\S]$/',$this->getConfirmation())); | ||
83 | + $statusMessage = $this->isTextPresent("Exclusão não realizada."); | ||
84 | + $this->assertTrue(!$statusMessage); | ||
85 | + | ||
86 | + $this->doLogout(); | ||
87 | + } | ||
88 | +} | ||
0 | \ No newline at end of file | 89 | \ No newline at end of file |
@@ -0,0 +1,59 @@ | @@ -0,0 +1,59 @@ | ||
1 | +<?php | ||
2 | + | ||
3 | +/** | ||
4 | + * i-Educar - Sistema de gestão escolar | ||
5 | + * | ||
6 | + * Copyright (C) 2006 Prefeitura Municipal de Itajaí | ||
7 | + * <ctima@itajai.sc.gov.br> | ||
8 | + * | ||
9 | + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo | ||
10 | + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free | ||
11 | + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) | ||
12 | + * qualquer versão posterior. | ||
13 | + * | ||
14 | + * Este programa é distribuído na expectativa de que seja útil, porém, SEM | ||
15 | + * NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU | ||
16 | + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral | ||
17 | + * do GNU para mais detalhes. | ||
18 | + * | ||
19 | + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto | ||
20 | + * com este programa; se não, escreva para a Free Software Foundation, Inc., no | ||
21 | + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | ||
22 | + * | ||
23 | + * @author Eriksen Costa Paixão <eriksen.paixao_bs@cobra.com.br> | ||
24 | + * @category i-Educar | ||
25 | + * @license @@license@@ | ||
26 | + * @package UnitTests | ||
27 | + * @since Arquivo disponível desde a versão 1.1.0 | ||
28 | + * @version $Id$ | ||
29 | + */ | ||
30 | + | ||
31 | +require_once 'App/AllTests.php'; | ||
32 | +require_once 'Core/AllTests.php'; | ||
33 | +require_once 'CoreExt/AllTests.php'; | ||
34 | +require_once 'Utils/AllTests.php'; | ||
35 | + | ||
36 | +/** | ||
37 | + * Unit_AllTests class. | ||
38 | + * | ||
39 | + * Arquivo de definição de suíte de testes unitários. | ||
40 | + * | ||
41 | + * @author Eriksen Costa Paixão <eriksen.paixao_bs@cobra.com.br> | ||
42 | + * @category i-Educar | ||
43 | + * @license @@license@@ | ||
44 | + * @package UnitTests | ||
45 | + * @since Classe disponível desde a versão 1.1.0 | ||
46 | + * @version @@package_version@@ | ||
47 | + */ | ||
48 | +class Unit_AllTests | ||
49 | +{ | ||
50 | + public static function suite() | ||
51 | + { | ||
52 | + $suite = new PHPUnit_Framework_TestSuite('Suíte de testes unitários do projeto'); | ||
53 | + $suite->addTest(App_AllTests::suite()); | ||
54 | + $suite->addTest(Core_AllTests::suite()); | ||
55 | + $suite->addTest(CoreExt_AllTests::suite()); | ||
56 | + $suite->addTest(Utils_AllTests::suite()); | ||
57 | + return $suite; | ||
58 | + } | ||
59 | +} | ||
0 | \ No newline at end of file | 60 | \ No newline at end of file |
@@ -0,0 +1,57 @@ | @@ -0,0 +1,57 @@ | ||
1 | +<?php | ||
2 | + | ||
3 | +/** | ||
4 | + * i-Educar - Sistema de gestão escolar | ||
5 | + * | ||
6 | + * Copyright (C) 2006 Prefeitura Municipal de Itajaí | ||
7 | + * <ctima@itajai.sc.gov.br> | ||
8 | + * | ||
9 | + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo | ||
10 | + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free | ||
11 | + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) | ||
12 | + * qualquer versão posterior. | ||
13 | + * | ||
14 | + * Este programa é distribuído na expectativa de que seja útil, porém, SEM | ||
15 | + * NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU | ||
16 | + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral | ||
17 | + * do GNU para mais detalhes. | ||
18 | + * | ||
19 | + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto | ||
20 | + * com este programa; se não, escreva para a Free Software Foundation, Inc., no | ||
21 | + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | ||
22 | + * | ||
23 | + * @author Eriksen Costa Paixão <eriksen.paixao_bs@cobra.com.br> | ||
24 | + * @category i-Educar | ||
25 | + * @license @@license@@ | ||
26 | + * @package App | ||
27 | + * @subpackage UnitTests | ||
28 | + * @since Arquivo disponível desde a versão 1.1.0 | ||
29 | + * @version $Id$ | ||
30 | + */ | ||
31 | + | ||
32 | +require_once 'App/Model/AllTests.php'; | ||
33 | +require_once 'App/Service/AllTests.php'; | ||
34 | + | ||
35 | +/** | ||
36 | + * App_AllTests class. | ||
37 | + * | ||
38 | + * Arquivo de definição de suíte para o pacote App. | ||
39 | + * | ||
40 | + * @author Eriksen Costa Paixão <eriksen.paixao_bs@cobra.com.br> | ||
41 | + * @category i-Educar | ||
42 | + * @license @@license@@ | ||
43 | + * @package App | ||
44 | + * @subpackage UnitTests | ||
45 | + * @since Classe disponível desde a versão 1.1.0 | ||
46 | + * @version @@package_version@@ | ||
47 | + */ | ||
48 | +class App_AllTests | ||
49 | +{ | ||
50 | + public static function suite() | ||
51 | + { | ||
52 | + $suite = new PHPUnit_Framework_TestSuite('Suíte de testes unitários de App'); | ||
53 | + $suite->addTest(App_Model_AllTests::suite()); | ||
54 | + $suite->addTest(App_Service_AllTests::suite()); | ||
55 | + return $suite; | ||
56 | + } | ||
57 | +} | ||
0 | \ No newline at end of file | 58 | \ No newline at end of file |
@@ -0,0 +1,55 @@ | @@ -0,0 +1,55 @@ | ||
1 | +<?php | ||
2 | + | ||
3 | +/** | ||
4 | + * i-Educar - Sistema de gestão escolar | ||
5 | + * | ||
6 | + * Copyright (C) 2006 Prefeitura Municipal de Itajaí | ||
7 | + * <ctima@itajai.sc.gov.br> | ||
8 | + * | ||
9 | + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo | ||
10 | + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free | ||
11 | + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) | ||
12 | + * qualquer versão posterior. | ||
13 | + * | ||
14 | + * Este programa é distribuído na expectativa de que seja útil, porém, SEM | ||
15 | + * NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU | ||
16 | + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral | ||
17 | + * do GNU para mais detalhes. | ||
18 | + * | ||
19 | + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto | ||
20 | + * com este programa; se não, escreva para a Free Software Foundation, Inc., no | ||
21 | + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | ||
22 | + * | ||
23 | + * @author Eriksen Costa Paixão <eriksen.paixao_bs@cobra.com.br> | ||
24 | + * @category i-Educar | ||
25 | + * @license @@license@@ | ||
26 | + * @package App_Model | ||
27 | + * @subpackage UnitTests | ||
28 | + * @since Arquivo disponível desde a versão 1.1.0 | ||
29 | + * @version $Id$ | ||
30 | + */ | ||
31 | + | ||
32 | +/** | ||
33 | + * App_Model_AllTests class. | ||
34 | + * | ||
35 | + * Arquivo de definição de suíte para o pacote App_Model. | ||
36 | + * | ||
37 | + * @author Eriksen Costa Paixão <eriksen.paixao_bs@cobra.com.br> | ||
38 | + * @category i-Educar | ||
39 | + * @license @@license@@ | ||
40 | + * @package App_Model | ||
41 | + * @subpackage UnitTests | ||
42 | + * @since Classe disponível desde a versão 1.1.0 | ||
43 | + * @version @@package_version@@ | ||
44 | + */ | ||
45 | +class App_Model_AllTests extends TestCollector | ||
46 | +{ | ||
47 | + protected $_name = 'Suíte de testes unitários de App_Model'; | ||
48 | + protected $_file = __FILE__; | ||
49 | + | ||
50 | + public static function suite() | ||
51 | + { | ||
52 | + $instance = new self(); | ||
53 | + return $instance->addDirectoryTests(); | ||
54 | + } | ||
55 | +} | ||
0 | \ No newline at end of file | 56 | \ No newline at end of file |
@@ -0,0 +1,55 @@ | @@ -0,0 +1,55 @@ | ||
1 | +<?php | ||
2 | + | ||
3 | +/** | ||
4 | + * i-Educar - Sistema de gestão escolar | ||
5 | + * | ||
6 | + * Copyright (C) 2006 Prefeitura Municipal de Itajaí | ||
7 | + * <ctima@itajai.sc.gov.br> | ||
8 | + * | ||
9 | + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo | ||
10 | + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free | ||
11 | + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) | ||
12 | + * qualquer versão posterior. | ||
13 | + * | ||
14 | + * Este programa é distribuído na expectativa de que seja útil, porém, SEM | ||
15 | + * NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU | ||
16 | + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral | ||
17 | + * do GNU para mais detalhes. | ||
18 | + * | ||
19 | + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto | ||
20 | + * com este programa; se não, escreva para a Free Software Foundation, Inc., no | ||
21 | + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | ||
22 | + * | ||
23 | + * @author Eriksen Costa Paixão <eriksen.paixao_bs@cobra.com.br> | ||
24 | + * @category i-Educar | ||
25 | + * @license @@license@@ | ||
26 | + * @package App_Service | ||
27 | + * @subpackage UnitTests | ||
28 | + * @since Arquivo disponível desde a versão 1.1.0 | ||
29 | + * @version $Id$ | ||
30 | + */ | ||
31 | + | ||
32 | +/** | ||
33 | + * App_Service_AllTests class. | ||
34 | + * | ||
35 | + * Arquivo de definição de suíte para o pacote App_Service. | ||
36 | + * | ||
37 | + * @author Eriksen Costa Paixão <eriksen.paixao_bs@cobra.com.br> | ||
38 | + * @category i-Educar | ||
39 | + * @license @@license@@ | ||
40 | + * @package App_Service | ||
41 | + * @subpackage UnitTests | ||
42 | + * @since Classe disponível desde a versão 1.1.0 | ||
43 | + * @version @@package_version@@ | ||
44 | + */ | ||
45 | +class App_Service_AllTests extends TestCollector | ||
46 | +{ | ||
47 | + protected $_name = 'Suíte de testes unitários de App_Service'; | ||
48 | + protected $_file = __FILE__; | ||
49 | + | ||
50 | + public static function suite() | ||
51 | + { | ||
52 | + $instance = new self(); | ||
53 | + return $instance->addDirectoryTests(); | ||
54 | + } | ||
55 | +} | ||
0 | \ No newline at end of file | 56 | \ No newline at end of file |
ieducar/tests/unit/ClsBancoTest.class.php
@@ -1,65 +0,0 @@ | @@ -1,65 +0,0 @@ | ||
1 | -<?php | ||
2 | - | ||
3 | -/* | ||
4 | - * i-Educar - Sistema de gestão escolar | ||
5 | - * | ||
6 | - * Copyright (C) 2006 Prefeitura Municipal de Itajaí | ||
7 | - * <ctima@itajai.sc.gov.br> | ||
8 | - * | ||
9 | - * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo | ||
10 | - * sob os termos da Licença Pública Geral GNU conforme publicada pela Free | ||
11 | - * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) | ||
12 | - * qualquer versão posterior. | ||
13 | - * | ||
14 | - * Este programa é distribuído na expectativa de que seja útil, porém, SEM | ||
15 | - * NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU | ||
16 | - * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral | ||
17 | - * do GNU para mais detalhes. | ||
18 | - * | ||
19 | - * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto | ||
20 | - * com este programa; se não, escreva para a Free Software Foundation, Inc., no | ||
21 | - * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | ||
22 | - * | ||
23 | - * @author Eriksen Costa Paixão <eriksen.paixao_bs@cobra.com.br> | ||
24 | - * @license http://creativecommons.org/licenses/GPL/2.0/legalcode.pt CC GNU GPL | ||
25 | - * @package Test | ||
26 | - * @subpackage UnitTest | ||
27 | - * @since Arquivo disponível desde a versão 1.0.1 | ||
28 | - * @version $Id$ | ||
29 | - */ | ||
30 | - | ||
31 | -require_once realpath(dirname(__FILE__) . '/../') . '/UnitBaseTest.class.php'; | ||
32 | -require_once 'include/pmieducar/clsPmieducarClienteSuspensao.inc.php'; | ||
33 | - | ||
34 | - | ||
35 | -/** | ||
36 | - * clsBancoTest class. | ||
37 | - * | ||
38 | - * @author Eriksen Costa Paixão <eriksen.paixao_bs@cobra.com.br> | ||
39 | - * @license http://creativecommons.org/licenses/GPL/2.0/legalcode.pt CC GNU GPL | ||
40 | - * @package Test | ||
41 | - * @subpackage UnitTest | ||
42 | - * @since Classe disponível desde a versão 1.0.1 | ||
43 | - * @version $Id$ | ||
44 | - */ | ||
45 | -class ClsBancoTest extends UnitBaseTest | ||
46 | -{ | ||
47 | - | ||
48 | - public function testDoCountFromObj() | ||
49 | - { | ||
50 | - $db = new clsBanco(); | ||
51 | - $db->Conecta(); | ||
52 | - | ||
53 | - $obj = new clsPmieducarClienteSuspensao(); | ||
54 | - $this->assertNotEquals(TRUE, is_null($db->doCountFromObj($obj))); | ||
55 | - } | ||
56 | - | ||
57 | - public function testConexao() | ||
58 | - { | ||
59 | - $db = new clsBanco(); | ||
60 | - $db->Conecta(); | ||
61 | - | ||
62 | - $this->assertTrue((bool) $db->bLink_ID); | ||
63 | - } | ||
64 | - | ||
65 | -} |
ieducar/tests/unit/ClsConfigItajaiTest.class.php
@@ -1,75 +0,0 @@ | @@ -1,75 +0,0 @@ | ||
1 | -<?php | ||
2 | - | ||
3 | -/* | ||
4 | - * i-Educar - Sistema de gestão escolar | ||
5 | - * | ||
6 | - * Copyright (C) 2006 Prefeitura Municipal de Itajaí | ||
7 | - * <ctima@itajai.sc.gov.br> | ||
8 | - * | ||
9 | - * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo | ||
10 | - * sob os termos da Licença Pública Geral GNU conforme publicada pela Free | ||
11 | - * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) | ||
12 | - * qualquer versão posterior. | ||
13 | - * | ||
14 | - * Este programa é distribuído na expectativa de que seja útil, porém, SEM | ||
15 | - * NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU | ||
16 | - * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral | ||
17 | - * do GNU para mais detalhes. | ||
18 | - * | ||
19 | - * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto | ||
20 | - * com este programa; se não, escreva para a Free Software Foundation, Inc., no | ||
21 | - * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | ||
22 | - */ | ||
23 | - | ||
24 | -require_once realpath(dirname(__FILE__) . '/../') . '/UnitBaseTest.class.php'; | ||
25 | -require_once 'clsConfigItajai.inc.php'; | ||
26 | - | ||
27 | - | ||
28 | -/** | ||
29 | - * clsConfigItajaiTest class. | ||
30 | - * | ||
31 | - * @author Eriksen Costa Paixão <eriksen.paixao_bs@cobra.com.br> | ||
32 | - * @license http://creativecommons.org/licenses/GPL/2.0/legalcode.pt CC GNU GPL | ||
33 | - * @package Test | ||
34 | - * @subpackage UnitTest | ||
35 | - * @since Classe disponível desde a versão 1.1.0 | ||
36 | - * @version $Id$ | ||
37 | - */ | ||
38 | -class ClsConfigItajai extends UnitBaseTest | ||
39 | -{ | ||
40 | - | ||
41 | - /** | ||
42 | - * @var clsConfig | ||
43 | - */ | ||
44 | - protected $config = NULL; | ||
45 | - | ||
46 | - protected function setUp() { | ||
47 | - $this->config = new clsConfig(); | ||
48 | - } | ||
49 | - | ||
50 | - public function testConfigInstituicao() { | ||
51 | - $this->assertEquals('i-Educar - ', $this->config->_instituicao); | ||
52 | - } | ||
53 | - | ||
54 | - public function testArrayConfigHasEmailsAdministradores() { | ||
55 | - $this->assertTrue((bool) count($this->config->arrayConfig['ArrStrEmailsAdministradores'])); | ||
56 | - } | ||
57 | - | ||
58 | - public function testArrayCheckEmailAdministradores() { | ||
59 | - $this->assertEquals('seu.email@example.com', | ||
60 | - $this->config->arrayConfig['ArrStrEmailsAdministradores'][0]); | ||
61 | - } | ||
62 | - | ||
63 | - public function testArrayConfigDirectoryTemplates() { | ||
64 | - $this->assertEquals('templates/', $this->config->arrayConfig['strDirTemplates']); | ||
65 | - } | ||
66 | - | ||
67 | - public function testArrayConfigIntSegundosQuerySql() { | ||
68 | - $this->assertEquals(3, $this->config->arrayConfig['intSegundosQuerySQL']); | ||
69 | - } | ||
70 | - | ||
71 | - public function testArrayConfigIntSegundosPagina() { | ||
72 | - $this->assertEquals(5, $this->config->arrayConfig['intSegundosProcessaPagina']); | ||
73 | - } | ||
74 | - | ||
75 | -} | ||
76 | \ No newline at end of file | 0 | \ No newline at end of file |
ieducar/tests/unit/ClsPmieducarQuadroHorarioHorariosTest.class.php
@@ -1,52 +0,0 @@ | @@ -1,52 +0,0 @@ | ||
1 | -<?php | ||
2 | - | ||
3 | -/* | ||
4 | - * i-Educar - Sistema de gestão escolar | ||
5 | - * | ||
6 | - * Copyright (C) 2006 Prefeitura Municipal de Itajaí | ||
7 | - * <ctima@itajai.sc.gov.br> | ||
8 | - * | ||
9 | - * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo | ||
10 | - * sob os termos da Licença Pública Geral GNU conforme publicada pela Free | ||
11 | - * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) | ||
12 | - * qualquer versão posterior. | ||
13 | - * | ||
14 | - * Este programa é distribuído na expectativa de que seja útil, porém, SEM | ||
15 | - * NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU | ||
16 | - * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral | ||
17 | - * do GNU para mais detalhes. | ||
18 | - * | ||
19 | - * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto | ||
20 | - * com este programa; se não, escreva para a Free Software Foundation, Inc., no | ||
21 | - * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | ||
22 | - */ | ||
23 | - | ||
24 | -/** | ||
25 | - * ClsPmieducarQuadroHorarioHorariosTest class | ||
26 | - * | ||
27 | - * @author Eriksen Costa Paixão <eriksen.paixao_bs@cobra.com.br> | ||
28 | - * @license http://creativecommons.org/licenses/GPL/2.0/legalcode.pt CC GNU GPL | ||
29 | - * @package Test | ||
30 | - * @since Classe disponível desde a versão 1.0.2 | ||
31 | - * @version $Id$ | ||
32 | - */ | ||
33 | - | ||
34 | -require_once realpath(dirname(__FILE__) . '/../') . '/UnitBaseTest.class.php'; | ||
35 | -require_once 'include/pmieducar/clsPmieducarQuadroHorarioHorarios.inc.php'; | ||
36 | - | ||
37 | -class ClsPmieducarQuadroHorarioHorariosTest extends UnitBaseTest { | ||
38 | - | ||
39 | - /** | ||
40 | - * Testa o método substituir_servidor() | ||
41 | - */ | ||
42 | - public function testSubstituirServidor() { | ||
43 | - $stub = $this->getMock('clsPmieducarQuadroHorarioHorarios'); | ||
44 | - | ||
45 | - $stub->expects($this->any()) | ||
46 | - ->method('substituir_servidor') | ||
47 | - ->will($this->returnValue(TRUE)); | ||
48 | - | ||
49 | - $this->assertTrue($stub->substituir_servidor(1)); | ||
50 | - } | ||
51 | - | ||
52 | -} | ||
53 | \ No newline at end of file | 0 | \ No newline at end of file |
ieducar/tests/unit/ClsPmieducarServidorAlocacaoTest.class.php
@@ -1,52 +0,0 @@ | @@ -1,52 +0,0 @@ | ||
1 | -<?php | ||
2 | - | ||
3 | -/* | ||
4 | - * i-Educar - Sistema de gestão escolar | ||
5 | - * | ||
6 | - * Copyright (C) 2006 Prefeitura Municipal de Itajaí | ||
7 | - * <ctima@itajai.sc.gov.br> | ||
8 | - * | ||
9 | - * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo | ||
10 | - * sob os termos da Licença Pública Geral GNU conforme publicada pela Free | ||
11 | - * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) | ||
12 | - * qualquer versão posterior. | ||
13 | - * | ||
14 | - * Este programa é distribuído na expectativa de que seja útil, porém, SEM | ||
15 | - * NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU | ||
16 | - * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral | ||
17 | - * do GNU para mais detalhes. | ||
18 | - * | ||
19 | - * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto | ||
20 | - * com este programa; se não, escreva para a Free Software Foundation, Inc., no | ||
21 | - * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | ||
22 | - */ | ||
23 | - | ||
24 | -/** | ||
25 | - * ClsPmieducarServidorAlocacaoTest class | ||
26 | - * | ||
27 | - * @author Eriksen Costa Paixão <eriksen.paixao_bs@cobra.com.br> | ||
28 | - * @license http://creativecommons.org/licenses/GPL/2.0/legalcode.pt CC GNU GPL | ||
29 | - * @package Test | ||
30 | - * @since Classe disponível desde a versão 1.0.2 | ||
31 | - * @version $Id$ | ||
32 | - */ | ||
33 | - | ||
34 | -require_once realpath(dirname(__FILE__) . '/../') . '/UnitBaseTest.class.php'; | ||
35 | -require_once 'include/pmieducar/clsPmieducarServidorAlocacao.inc.php'; | ||
36 | - | ||
37 | -class ClsPmieducarServidorAlocacaoTest extends UnitBaseTest { | ||
38 | - | ||
39 | - /** | ||
40 | - * Testa o método substituir_servidor() | ||
41 | - */ | ||
42 | - public function testSubstituirServidor() { | ||
43 | - $stub = $this->getMock('clsPmieducarServidorAlocacao'); | ||
44 | - | ||
45 | - $stub->expects($this->any()) | ||
46 | - ->method('substituir_servidor') | ||
47 | - ->will($this->returnValue(TRUE)); | ||
48 | - | ||
49 | - $this->assertTrue($stub->substituir_servidor(1)); | ||
50 | - } | ||
51 | - | ||
52 | -} | ||
53 | \ No newline at end of file | 0 | \ No newline at end of file |
@@ -0,0 +1,57 @@ | @@ -0,0 +1,57 @@ | ||
1 | +<?php | ||
2 | + | ||
3 | +/** | ||
4 | + * i-Educar - Sistema de gestão escolar | ||
5 | + * | ||
6 | + * Copyright (C) 2006 Prefeitura Municipal de Itajaí | ||
7 | + * <ctima@itajai.sc.gov.br> | ||
8 | + * | ||
9 | + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo | ||
10 | + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free | ||
11 | + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) | ||
12 | + * qualquer versão posterior. | ||
13 | + * | ||
14 | + * Este programa é distribuído na expectativa de que seja útil, porém, SEM | ||
15 | + * NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU | ||
16 | + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral | ||
17 | + * do GNU para mais detalhes. | ||
18 | + * | ||
19 | + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto | ||
20 | + * com este programa; se não, escreva para a Free Software Foundation, Inc., no | ||
21 | + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | ||
22 | + * | ||
23 | + * @author Eriksen Costa Paixão <eriksen.paixao_bs@cobra.com.br> | ||
24 | + * @category i-Educar | ||
25 | + * @license @@license@@ | ||
26 | + * @package Core | ||
27 | + * @subpackage UnitTests | ||
28 | + * @since Arquivo disponível desde a versão 1.1.0 | ||
29 | + * @version $Id$ | ||
30 | + */ | ||
31 | + | ||
32 | +require_once 'App/Model/AllTests.php'; | ||
33 | + | ||
34 | +/** | ||
35 | + * Core_AllTests class. | ||
36 | + * | ||
37 | + * Arquivo de definição de suíte para o pacote Core (objetos legados). | ||
38 | + * | ||
39 | + * @author Eriksen Costa Paixão <eriksen.paixao_bs@cobra.com.br> | ||
40 | + * @category i-Educar | ||
41 | + * @license @@license@@ | ||
42 | + * @package Core | ||
43 | + * @subpackage UnitTests | ||
44 | + * @since Classe disponível desde a versão 1.1.0 | ||
45 | + * @version @@package_version@@ | ||
46 | + */ | ||
47 | +class Core_AllTests extends TestCollector | ||
48 | +{ | ||
49 | + protected $_name = 'Suíte de testes unitários de Core (objetos legados)'; | ||
50 | + protected $_file = __FILE__; | ||
51 | + | ||
52 | + public static function suite() | ||
53 | + { | ||
54 | + $instance = new self; | ||
55 | + return $instance->addDirectoryTests(); | ||
56 | + } | ||
57 | +} | ||
0 | \ No newline at end of file | 58 | \ No newline at end of file |
@@ -0,0 +1,64 @@ | @@ -0,0 +1,64 @@ | ||
1 | +<?php | ||
2 | + | ||
3 | +/** | ||
4 | + * i-Educar - Sistema de gestão escolar | ||
5 | + * | ||
6 | + * Copyright (C) 2006 Prefeitura Municipal de Itajaí | ||
7 | + * <ctima@itajai.sc.gov.br> | ||
8 | + * | ||
9 | + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo | ||
10 | + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free | ||
11 | + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) | ||
12 | + * qualquer versão posterior. | ||
13 | + * | ||
14 | + * Este programa é distribuído na expectativa de que seja útil, porém, SEM | ||
15 | + * NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU | ||
16 | + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral | ||
17 | + * do GNU para mais detalhes. | ||
18 | + * | ||
19 | + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto | ||
20 | + * com este programa; se não, escreva para a Free Software Foundation, Inc., no | ||
21 | + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | ||
22 | + * | ||
23 | + * @author Eriksen Costa Paixão <eriksen.paixao_bs@cobra.com.br> | ||
24 | + * @category i-Educar | ||
25 | + * @license @@license@@ | ||
26 | + * @package Core | ||
27 | + * @subpackage UnitTests | ||
28 | + * @since Arquivo disponível desde a versão 1.0.1 | ||
29 | + * @version $Id$ | ||
30 | + */ | ||
31 | + | ||
32 | +require_once 'include/pmieducar/clsPmieducarClienteSuspensao.inc.php'; | ||
33 | + | ||
34 | +/** | ||
35 | + * clsBancoTest class. | ||
36 | + * | ||
37 | + * @author Eriksen Costa Paixão <eriksen.paixao_bs@cobra.com.br> | ||
38 | + * @category i-Educar | ||
39 | + * @license @@license@@ | ||
40 | + * @package Core | ||
41 | + * @subpackage UnitTests | ||
42 | + * @since Classe disponível desde a versão 1.0.1 | ||
43 | + * @todo Mover método testConexao() para o pacote FunctionalTests | ||
44 | + * @version @@package_version@@ | ||
45 | + */ | ||
46 | +class ClsBancoTest extends UnitBaseTest | ||
47 | +{ | ||
48 | + public function testDoCountFromObj() | ||
49 | + { | ||
50 | + $db = new clsBanco(); | ||
51 | + $db->Conecta(); | ||
52 | + | ||
53 | + $obj = new clsPmieducarClienteSuspensao(); | ||
54 | + $this->assertNotEquals(TRUE, is_null($db->doCountFromObj($obj))); | ||
55 | + } | ||
56 | + | ||
57 | + public function testConexao() | ||
58 | + { | ||
59 | + $db = new clsBanco(); | ||
60 | + $db->Conecta(); | ||
61 | + | ||
62 | + $this->assertTrue((bool) $db->bLink_ID); | ||
63 | + } | ||
64 | +} | ||
0 | \ No newline at end of file | 65 | \ No newline at end of file |
@@ -0,0 +1,85 @@ | @@ -0,0 +1,85 @@ | ||
1 | +<?php | ||
2 | + | ||
3 | +/** | ||
4 | + * i-Educar - Sistema de gestão escolar | ||
5 | + * | ||
6 | + * Copyright (C) 2006 Prefeitura Municipal de Itajaí | ||
7 | + * <ctima@itajai.sc.gov.br> | ||
8 | + * | ||
9 | + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo | ||
10 | + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free | ||
11 | + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) | ||
12 | + * qualquer versão posterior. | ||
13 | + * | ||
14 | + * Este programa é distribuído na expectativa de que seja útil, porém, SEM | ||
15 | + * NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU | ||
16 | + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral | ||
17 | + * do GNU para mais detalhes. | ||
18 | + * | ||
19 | + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto | ||
20 | + * com este programa; se não, escreva para a Free Software Foundation, Inc., no | ||
21 | + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | ||
22 | + * | ||
23 | + * @author Eriksen Costa Paixão <eriksen.paixao_bs@cobra.com.br> | ||
24 | + * @category i-Educar | ||
25 | + * @license @@license@@ | ||
26 | + * @package Core | ||
27 | + * @subpackage UnitTests | ||
28 | + * @since Arquivo disponível desde a versão 1.1.0 | ||
29 | + * @version $Id$ | ||
30 | + */ | ||
31 | + | ||
32 | +require_once 'clsConfigItajai.inc.php'; | ||
33 | + | ||
34 | + | ||
35 | +/** | ||
36 | + * clsConfigItajaiTest class. | ||
37 | + * | ||
38 | + * @author Eriksen Costa Paixão <eriksen.paixao_bs@cobra.com.br> | ||
39 | + * @category i-Educar | ||
40 | + * @license @@license@@ | ||
41 | + * @package Core | ||
42 | + * @subpackage UnitTests | ||
43 | + * @since Classe disponível desde a versão 1.0.1 | ||
44 | + * @version @@package_version@@ | ||
45 | + */ | ||
46 | +class ClsConfigItajai extends UnitBaseTest | ||
47 | +{ | ||
48 | + protected $config = NULL; | ||
49 | + | ||
50 | + protected function setUp() | ||
51 | + { | ||
52 | + $this->config = new clsConfig(); | ||
53 | + } | ||
54 | + | ||
55 | + public function testConfigInstituicao() | ||
56 | + { | ||
57 | + $this->assertEquals('i-Educar - ', $this->config->_instituicao); | ||
58 | + } | ||
59 | + | ||
60 | + public function testArrayConfigHasEmailsAdministradores() | ||
61 | + { | ||
62 | + $this->assertTrue((bool) count($this->config->arrayConfig['ArrStrEmailsAdministradores'])); | ||
63 | + } | ||
64 | + | ||
65 | + public function testArrayCheckEmailAdministradores() | ||
66 | + { | ||
67 | + $this->assertEquals('seu.email@example.com', | ||
68 | + $this->config->arrayConfig['ArrStrEmailsAdministradores'][0]); | ||
69 | + } | ||
70 | + | ||
71 | + public function testArrayConfigDirectoryTemplates() | ||
72 | + { | ||
73 | + $this->assertEquals('templates/', $this->config->arrayConfig['strDirTemplates']); | ||
74 | + } | ||
75 | + | ||
76 | + public function testArrayConfigIntSegundosQuerySql() | ||
77 | + { | ||
78 | + $this->assertEquals(3, $this->config->arrayConfig['intSegundosQuerySQL']); | ||
79 | + } | ||
80 | + | ||
81 | + public function testArrayConfigIntSegundosPagina() | ||
82 | + { | ||
83 | + $this->assertEquals(5, $this->config->arrayConfig['intSegundosProcessaPagina']); | ||
84 | + } | ||
85 | +} | ||
0 | \ No newline at end of file | 86 | \ No newline at end of file |
ieducar/tests/unit/Core/ClsPmieducarQuadroHorarioHorariosTest.php
0 → 100644
@@ -0,0 +1,60 @@ | @@ -0,0 +1,60 @@ | ||
1 | +<?php | ||
2 | + | ||
3 | +/** | ||
4 | + * i-Educar - Sistema de gestão escolar | ||
5 | + * | ||
6 | + * Copyright (C) 2006 Prefeitura Municipal de Itajaí | ||
7 | + * <ctima@itajai.sc.gov.br> | ||
8 | + * | ||
9 | + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo | ||
10 | + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free | ||
11 | + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) | ||
12 | + * qualquer versão posterior. | ||
13 | + * | ||
14 | + * Este programa é distribuído na expectativa de que seja útil, porém, SEM | ||
15 | + * NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU | ||
16 | + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral | ||
17 | + * do GNU para mais detalhes. | ||
18 | + * | ||
19 | + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto | ||
20 | + * com este programa; se não, escreva para a Free Software Foundation, Inc., no | ||
21 | + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | ||
22 | + * | ||
23 | + * @author Eriksen Costa Paixão <eriksen.paixao_bs@cobra.com.br> | ||
24 | + * @category i-Educar | ||
25 | + * @license @@license@@ | ||
26 | + * @package Core | ||
27 | + * @subpackage UnitTests | ||
28 | + * @since Arquivo disponível desde a versão 1.0.2 | ||
29 | + * @version $Id$ | ||
30 | + */ | ||
31 | + | ||
32 | +require_once 'include/pmieducar/clsPmieducarQuadroHorarioHorarios.inc.php'; | ||
33 | + | ||
34 | +/** | ||
35 | + * ClsPmieducarQuadroHorarioHorariosTest class. | ||
36 | + * | ||
37 | + * @author Eriksen Costa Paixão <eriksen.paixao_bs@cobra.com.br> | ||
38 | + * @category i-Educar | ||
39 | + * @license @@license@@ | ||
40 | + * @package Core | ||
41 | + * @subpackage UnitTests | ||
42 | + * @since Classe disponível desde a versão 1.0.2 | ||
43 | + * @version @@package_version@@ | ||
44 | + */ | ||
45 | +class ClsPmieducarQuadroHorarioHorariosTest extends UnitBaseTest | ||
46 | +{ | ||
47 | + /** | ||
48 | + * Testa o método substituir_servidor() | ||
49 | + */ | ||
50 | + public function testSubstituirServidor() | ||
51 | + { | ||
52 | + $stub = $this->getMock('clsPmieducarQuadroHorarioHorarios'); | ||
53 | + | ||
54 | + $stub->expects($this->any()) | ||
55 | + ->method('substituir_servidor') | ||
56 | + ->will($this->returnValue(TRUE)); | ||
57 | + | ||
58 | + $this->assertTrue($stub->substituir_servidor(1)); | ||
59 | + } | ||
60 | +} | ||
0 | \ No newline at end of file | 61 | \ No newline at end of file |
ieducar/tests/unit/Core/ClsPmieducarServidorAlocacaoTest.php
0 → 100644
@@ -0,0 +1,60 @@ | @@ -0,0 +1,60 @@ | ||
1 | +<?php | ||
2 | + | ||
3 | +/** | ||
4 | + * i-Educar - Sistema de gestão escolar | ||
5 | + * | ||
6 | + * Copyright (C) 2006 Prefeitura Municipal de Itajaí | ||
7 | + * <ctima@itajai.sc.gov.br> | ||
8 | + * | ||
9 | + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo | ||
10 | + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free | ||
11 | + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) | ||
12 | + * qualquer versão posterior. | ||
13 | + * | ||
14 | + * Este programa é distribuído na expectativa de que seja útil, porém, SEM | ||
15 | + * NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU | ||
16 | + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral | ||
17 | + * do GNU para mais detalhes. | ||
18 | + * | ||
19 | + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto | ||
20 | + * com este programa; se não, escreva para a Free Software Foundation, Inc., no | ||
21 | + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | ||
22 | + * | ||
23 | + * @author Eriksen Costa Paixão <eriksen.paixao_bs@cobra.com.br> | ||
24 | + * @category i-Educar | ||
25 | + * @license @@license@@ | ||
26 | + * @package Core | ||
27 | + * @subpackage UnitTests | ||
28 | + * @since Arquivo disponível desde a versão 1.0.2 | ||
29 | + * @version $Id$ | ||
30 | + */ | ||
31 | + | ||
32 | +require_once 'include/pmieducar/clsPmieducarServidorAlocacao.inc.php'; | ||
33 | + | ||
34 | +/** | ||
35 | + * ClsPmieducarServidorAlocacaoTest class. | ||
36 | + * | ||
37 | + * @author Eriksen Costa Paixão <eriksen.paixao_bs@cobra.com.br> | ||
38 | + * @category i-Educar | ||
39 | + * @license @@license@@ | ||
40 | + * @package Core | ||
41 | + * @subpackage UnitTests | ||
42 | + * @since Classe disponível desde a versão 1.0.2 | ||
43 | + * @version @@package_version@@ | ||
44 | + */ | ||
45 | +class ClsPmieducarServidorAlocacaoTest extends UnitBaseTest | ||
46 | +{ | ||
47 | + /** | ||
48 | + * Testa o método substituir_servidor(). | ||
49 | + */ | ||
50 | + public function testSubstituirServidor() | ||
51 | + { | ||
52 | + $stub = $this->getMock('clsPmieducarServidorAlocacao'); | ||
53 | + | ||
54 | + $stub->expects($this->any()) | ||
55 | + ->method('substituir_servidor') | ||
56 | + ->will($this->returnValue(TRUE)); | ||
57 | + | ||
58 | + $this->assertTrue($stub->substituir_servidor(1)); | ||
59 | + } | ||
60 | +} | ||
0 | \ No newline at end of file | 61 | \ No newline at end of file |
@@ -0,0 +1,55 @@ | @@ -0,0 +1,55 @@ | ||
1 | +<?php | ||
2 | + | ||
3 | +/** | ||
4 | + * i-Educar - Sistema de gestão escolar | ||
5 | + * | ||
6 | + * Copyright (C) 2006 Prefeitura Municipal de Itajaí | ||
7 | + * <ctima@itajai.sc.gov.br> | ||
8 | + * | ||
9 | + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo | ||
10 | + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free | ||
11 | + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) | ||
12 | + * qualquer versão posterior. | ||
13 | + * | ||
14 | + * Este programa é distribuído na expectativa de que seja útil, porém, SEM | ||
15 | + * NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU | ||
16 | + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral | ||
17 | + * do GNU para mais detalhes. | ||
18 | + * | ||
19 | + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto | ||
20 | + * com este programa; se não, escreva para a Free Software Foundation, Inc., no | ||
21 | + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | ||
22 | + * | ||
23 | + * @author Eriksen Costa Paixão <eriksen.paixao_bs@cobra.com.br> | ||
24 | + * @category i-Educar | ||
25 | + * @license @@license@@ | ||
26 | + * @package CoreExt | ||
27 | + * @subpackage UnitTests | ||
28 | + * @since Arquivo disponível desde a versão 1.1.0 | ||
29 | + * @version $Id$ | ||
30 | + */ | ||
31 | + | ||
32 | +/** | ||
33 | + * CoreExt_AllTests class. | ||
34 | + * | ||
35 | + * Arquivo de definição de suíte para o pacote CoreExt (nova API). | ||
36 | + * | ||
37 | + * @author Eriksen Costa Paixão <eriksen.paixao_bs@cobra.com.br> | ||
38 | + * @category i-Educar | ||
39 | + * @license @@license@@ | ||
40 | + * @package CoreExt | ||
41 | + * @subpackage UnitTests | ||
42 | + * @since Classe disponível desde a versão 1.1.0 | ||
43 | + * @version @@package_version@@ | ||
44 | + */ | ||
45 | +class CoreExt_AllTests extends TestCollector | ||
46 | +{ | ||
47 | + protected $_name = 'Suíte de testes unitários de CoreExt'; | ||
48 | + protected $_file = __FILE__; | ||
49 | + | ||
50 | + public static function suite() | ||
51 | + { | ||
52 | + $instance = new self; | ||
53 | + return $instance->addDirectoryTests(); | ||
54 | + } | ||
55 | +} | ||
0 | \ No newline at end of file | 56 | \ No newline at end of file |
@@ -0,0 +1,145 @@ | @@ -0,0 +1,145 @@ | ||
1 | +<?php | ||
2 | + | ||
3 | +/** | ||
4 | + * i-Educar - Sistema de gestão escolar | ||
5 | + * | ||
6 | + * Copyright (C) 2006 Prefeitura Municipal de Itajaí | ||
7 | + * <ctima@itajai.sc.gov.br> | ||
8 | + * | ||
9 | + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo | ||
10 | + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free | ||
11 | + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) | ||
12 | + * qualquer versão posterior. | ||
13 | + * | ||
14 | + * Este programa é distribuído na expectativa de que seja útil, porém, SEM | ||
15 | + * NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU | ||
16 | + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral | ||
17 | + * do GNU para mais detalhes. | ||
18 | + * | ||
19 | + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto | ||
20 | + * com este programa; se não, escreva para a Free Software Foundation, Inc., no | ||
21 | + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | ||
22 | + * | ||
23 | + * @author Eriksen Costa Paixão <eriksen.paixao_bs@cobra.com.br> | ||
24 | + * @category i-Educar | ||
25 | + * @license @@license@@ | ||
26 | + * @package CoreExt | ||
27 | + * @subpackage UnitTests | ||
28 | + * @since Arquivo disponível desde a versão 1.1.0 | ||
29 | + * @version $Id$ | ||
30 | + */ | ||
31 | + | ||
32 | +require_once 'CoreExt/Config.class.php'; | ||
33 | + | ||
34 | +/** | ||
35 | + * CoreExt_ConfigTest class. | ||
36 | + * | ||
37 | + * @author Eriksen Costa Paixão <eriksen.paixao_bs@cobra.com.br> | ||
38 | + * @category i-Educar | ||
39 | + * @license @@license@@ | ||
40 | + * @package CoreExt | ||
41 | + * @subpackage UnitTests | ||
42 | + * @since Classe disponível desde a versão 1.1.0 | ||
43 | + * @version @@package_version@@ | ||
44 | + */ | ||
45 | +class CoreExt_ConfigTest extends UnitBaseTest | ||
46 | +{ | ||
47 | + public function testConfigHasValueFromArray() | ||
48 | + { | ||
49 | + $arr = array( | ||
50 | + 'app' => array( | ||
51 | + 'database' => array( | ||
52 | + 'dbname' => 'ieducardb', | ||
53 | + 'username' => 'ieducaruser', | ||
54 | + 'password' => '12345678' | ||
55 | + ) | ||
56 | + ), | ||
57 | + 'version' => 'Development' | ||
58 | + ); | ||
59 | + | ||
60 | + $config = new CoreExt_Config($arr); | ||
61 | + $this->assertEquals('ieducardb', $config->app->database->dbname); | ||
62 | + $this->assertEquals('Development', $config->version); | ||
63 | + } | ||
64 | + | ||
65 | + public function testHasOneItem() | ||
66 | + { | ||
67 | + $arr = array( | ||
68 | + 'app' => array('database' => '') | ||
69 | + ); | ||
70 | + | ||
71 | + $config = new CoreExt_Config($arr); | ||
72 | + $this->assertEquals(1, $config->count()); | ||
73 | + } | ||
74 | + | ||
75 | + public function testHasTwoItems() | ||
76 | + { | ||
77 | + $arr = array( | ||
78 | + 'app' => array('database' => '', 'template' => ''), | ||
79 | + 'php' => '' | ||
80 | + ); | ||
81 | + | ||
82 | + $config = new CoreExt_Config($arr); | ||
83 | + $this->assertEquals(2, $config->count()); | ||
84 | + $this->assertEquals(2, $config->app->count()); | ||
85 | + } | ||
86 | + | ||
87 | + /** | ||
88 | + * @expectedException Exception | ||
89 | + */ | ||
90 | + public function testGetNotExistNotProvidingDefaultValue() | ||
91 | + { | ||
92 | + $arr = array('app' => array('database' => array('dbname' => 'ieducardb'))); | ||
93 | + | ||
94 | + $config = new CoreExt_Config($arr); | ||
95 | + $hostname = $config->get($config->app->database->hostname); | ||
96 | + $this->assertEquals($hostname, '127.0.0.1'); | ||
97 | + } | ||
98 | + | ||
99 | + public function testGetNotExistProvidingDefaultValue() | ||
100 | + { | ||
101 | + $arr = array('app' => array('database' => array('dbname' => 'ieducardb'))); | ||
102 | + | ||
103 | + $config = new CoreExt_Config($arr); | ||
104 | + $hostname = $config->get($config->app->database->hostname, '127.0.0.1'); | ||
105 | + $this->assertEquals($hostname, '127.0.0.1'); | ||
106 | + } | ||
107 | + | ||
108 | + public function testGetExistProvidingDefaultValue() | ||
109 | + { | ||
110 | + $arr = array('app' => array('database' => array('dbname' => 'ieducardb'))); | ||
111 | + | ||
112 | + $config = new CoreExt_Config($arr); | ||
113 | + $hostname = $config->get($config->app->database->dbname, '127.0.0.1'); | ||
114 | + $this->assertEquals($hostname, 'ieducardb'); | ||
115 | + } | ||
116 | + | ||
117 | + public function testObjectIterates() | ||
118 | + { | ||
119 | + $arr = array( | ||
120 | + 'index1' => 1, | ||
121 | + 'index2' => 2 | ||
122 | + ); | ||
123 | + | ||
124 | + $config = new CoreExt_Config($arr); | ||
125 | + | ||
126 | + $this->assertEquals(1, $config->current()); | ||
127 | + | ||
128 | + $config->next(); | ||
129 | + $this->assertEquals(2, $config->current()); | ||
130 | + | ||
131 | + foreach ($config as $key => $val) {} | ||
132 | + | ||
133 | + $config->rewind(); | ||
134 | + $this->assertEquals(1, $config->current()); | ||
135 | + } | ||
136 | + | ||
137 | + public function testTransformObjectInArray() | ||
138 | + { | ||
139 | + $arr = array(6, 3, 3); | ||
140 | + | ||
141 | + $config = new CoreExt_Config($arr); | ||
142 | + | ||
143 | + $this->assertEquals($arr, $config->toArray()); | ||
144 | + } | ||
145 | +} | ||
0 | \ No newline at end of file | 146 | \ No newline at end of file |
@@ -0,0 +1,100 @@ | @@ -0,0 +1,100 @@ | ||
1 | +<?php | ||
2 | + | ||
3 | +/** | ||
4 | + * i-Educar - Sistema de gestão escolar | ||
5 | + * | ||
6 | + * Copyright (C) 2006 Prefeitura Municipal de Itajaí | ||
7 | + * <ctima@itajai.sc.gov.br> | ||
8 | + * | ||
9 | + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo | ||
10 | + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free | ||
11 | + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) | ||
12 | + * qualquer versão posterior. | ||
13 | + * | ||
14 | + * Este programa é distribuído na expectativa de que seja útil, porém, SEM | ||
15 | + * NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU | ||
16 | + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral | ||
17 | + * do GNU para mais detalhes. | ||
18 | + * | ||
19 | + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto | ||
20 | + * com este programa; se não, escreva para a Free Software Foundation, Inc., no | ||
21 | + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | ||
22 | + * | ||
23 | + * @author Eriksen Costa Paixão <eriksen.paixao_bs@cobra.com.br> | ||
24 | + * @category i-Educar | ||
25 | + * @license @@license@@ | ||
26 | + * @package CoreExt | ||
27 | + * @subpackage UnitTests | ||
28 | + * @since Arquivo disponível desde a versão 1.1.0 | ||
29 | + * @version $Id$ | ||
30 | + */ | ||
31 | + | ||
32 | +require_once 'CoreExt/Config/Ini.class.php'; | ||
33 | + | ||
34 | +/** | ||
35 | + * CoreExt_Config_IniTest class. | ||
36 | + * | ||
37 | + * @author Eriksen Costa Paixão <eriksen.paixao_bs@cobra.com.br> | ||
38 | + * @category i-Educar | ||
39 | + * @license @@license@@ | ||
40 | + * @package CoreExt | ||
41 | + * @subpackage UnitTests | ||
42 | + * @since Classe disponível desde a versão 1.1.0 | ||
43 | + * @version @@package_version@@ | ||
44 | + */ | ||
45 | +class CoreExt_Config_IniTest extends UnitBaseTest | ||
46 | +{ | ||
47 | + public function testParsedIni() | ||
48 | + { | ||
49 | + $ini = new CoreExt_Config_Ini('../tests/fixtures/configuration/ieducar.ini'); | ||
50 | + $this->assertNotNull($ini->app); | ||
51 | + } | ||
52 | + | ||
53 | + public function testChangeEnviroment() | ||
54 | + { | ||
55 | + $ini = new CoreExt_Config_Ini('../tests/fixtures/configuration/ieducar.ini'); | ||
56 | + $this->assertEquals(FALSE, (bool) $ini->php->display_errors); | ||
57 | + | ||
58 | + $ini->changeEnviroment('development'); | ||
59 | + $this->assertEquals(TRUE, (bool) $ini->php->display_errors); | ||
60 | + | ||
61 | + $ini->changeEnviroment('testing'); | ||
62 | + $this->assertEquals(TRUE, (bool) $ini->php->display_errors); | ||
63 | + | ||
64 | + $ini->changeEnviroment(); | ||
65 | + $this->assertEquals(FALSE, (bool) $ini->php->display_errors); | ||
66 | + } | ||
67 | + | ||
68 | + /** | ||
69 | + * @expectedException Exception | ||
70 | + */ | ||
71 | + public function testInvalidIniFile() | ||
72 | + { | ||
73 | + // Tentando carregar configuração do blackhole! | ||
74 | + $ini = new CoreExt_Config_Ini('/dev/null'); | ||
75 | + } | ||
76 | + | ||
77 | + /** | ||
78 | + * @expectedException Exception | ||
79 | + */ | ||
80 | + public function testSectionExtendsMoreThanOne() | ||
81 | + { | ||
82 | + $ini = new CoreExt_Config_Ini('../tests/fixtures/configuration/ieducar-extends-broken.ini'); | ||
83 | + } | ||
84 | + | ||
85 | + /** | ||
86 | + * @expectedException Exception | ||
87 | + */ | ||
88 | + public function testIniSyntaxError() | ||
89 | + { | ||
90 | + $ini = new CoreExt_Config_Ini('../tests/fixtures/configuration/ieducar-syntax-broken.ini'); | ||
91 | + } | ||
92 | + | ||
93 | + /** | ||
94 | + * @expectedException Exception | ||
95 | + */ | ||
96 | + public function testSectionInheritanceNotExist() | ||
97 | + { | ||
98 | + $ini = new CoreExt_Config_Ini('../tests/fixtures/configuration/ieducar-inheritance-broken.ini'); | ||
99 | + } | ||
100 | +} | ||
0 | \ No newline at end of file | 101 | \ No newline at end of file |
ieducar/tests/unit/CoreExt_ConfigTest.class.php
@@ -1,137 +0,0 @@ | @@ -1,137 +0,0 @@ | ||
1 | -<?php | ||
2 | - | ||
3 | -/* | ||
4 | - * i-Educar - Sistema de gestão escolar | ||
5 | - * | ||
6 | - * Copyright (C) 2006 Prefeitura Municipal de Itajaí | ||
7 | - * <ctima@itajai.sc.gov.br> | ||
8 | - * | ||
9 | - * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo | ||
10 | - * sob os termos da Licença Pública Geral GNU conforme publicada pela Free | ||
11 | - * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) | ||
12 | - * qualquer versão posterior. | ||
13 | - * | ||
14 | - * Este programa é distribuído na expectativa de que seja útil, porém, SEM | ||
15 | - * NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU | ||
16 | - * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral | ||
17 | - * do GNU para mais detalhes. | ||
18 | - * | ||
19 | - * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto | ||
20 | - * com este programa; se não, escreva para a Free Software Foundation, Inc., no | ||
21 | - * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | ||
22 | - */ | ||
23 | - | ||
24 | -require_once realpath(dirname(__FILE__) . '/../') . '/UnitBaseTest.class.php'; | ||
25 | -require_once '../lib/CoreExt/Config.class.php'; | ||
26 | - | ||
27 | - | ||
28 | -/** | ||
29 | - * CoreExt_ConfigTest class | ||
30 | - * | ||
31 | - * @author Eriksen Costa Paixão <eriksen.paixao_bs@cobra.com.br> | ||
32 | - * @license http://creativecommons.org/licenses/GPL/2.0/legalcode.pt CC GNU GPL | ||
33 | - * @package Test | ||
34 | - * @since Classe disponível desde a versão 1.1.0 | ||
35 | - * @version $Id$ | ||
36 | - */ | ||
37 | -class CoreExt_ConfigTest extends UnitBaseTest | ||
38 | -{ | ||
39 | - | ||
40 | - public function testConfigHasValueFromArray() | ||
41 | - { | ||
42 | - $arr = array( | ||
43 | - 'app' => array( | ||
44 | - 'database' => array( | ||
45 | - 'dbname' => 'ieducardb', | ||
46 | - 'username' => 'ieducaruser', | ||
47 | - 'password' => '12345678' | ||
48 | - ) | ||
49 | - ), | ||
50 | - 'version' => 'Development' | ||
51 | - ); | ||
52 | - | ||
53 | - $config = new CoreExt_Config($arr); | ||
54 | - $this->assertEquals('ieducardb', $config->app->database->dbname); | ||
55 | - $this->assertEquals('Development', $config->version); | ||
56 | - } | ||
57 | - | ||
58 | - public function testHasOneItem() | ||
59 | - { | ||
60 | - $arr = array( | ||
61 | - 'app' => array('database' => '') | ||
62 | - ); | ||
63 | - | ||
64 | - $config = new CoreExt_Config($arr); | ||
65 | - $this->assertEquals(1, $config->count()); | ||
66 | - } | ||
67 | - | ||
68 | - public function testHasTwoItems() { | ||
69 | - $arr = array( | ||
70 | - 'app' => array('database' => '', 'template' => ''), | ||
71 | - 'php' => '' | ||
72 | - ); | ||
73 | - | ||
74 | - $config = new CoreExt_Config($arr); | ||
75 | - $this->assertEquals(2, $config->count()); | ||
76 | - $this->assertEquals(2, $config->app->count()); | ||
77 | - } | ||
78 | - | ||
79 | - /** | ||
80 | - * @expectedException Exception | ||
81 | - */ | ||
82 | - public function testGetNotExistNotProvidingDefaultValue() | ||
83 | - { | ||
84 | - $arr = array('app' => array('database' => array('dbname' => 'ieducardb'))); | ||
85 | - | ||
86 | - $config = new CoreExt_Config($arr); | ||
87 | - $hostname = $config->get($config->app->database->hostname); | ||
88 | - $this->assertEquals($hostname, '127.0.0.1'); | ||
89 | - } | ||
90 | - | ||
91 | - public function testGetNotExistProvidingDefaultValue() | ||
92 | - { | ||
93 | - $arr = array('app' => array('database' => array('dbname' => 'ieducardb'))); | ||
94 | - | ||
95 | - $config = new CoreExt_Config($arr); | ||
96 | - $hostname = $config->get($config->app->database->hostname, '127.0.0.1'); | ||
97 | - $this->assertEquals($hostname, '127.0.0.1'); | ||
98 | - } | ||
99 | - | ||
100 | - public function testGetExistProvidingDefaultValue() | ||
101 | - { | ||
102 | - $arr = array('app' => array('database' => array('dbname' => 'ieducardb'))); | ||
103 | - | ||
104 | - $config = new CoreExt_Config($arr); | ||
105 | - $hostname = $config->get($config->app->database->dbname, '127.0.0.1'); | ||
106 | - $this->assertEquals($hostname, 'ieducardb'); | ||
107 | - } | ||
108 | - | ||
109 | - public function testObjectIterates() | ||
110 | - { | ||
111 | - $arr = array( | ||
112 | - 'index1' => 1, | ||
113 | - 'index2' => 2 | ||
114 | - ); | ||
115 | - | ||
116 | - $config = new CoreExt_Config($arr); | ||
117 | - | ||
118 | - $this->assertEquals(1, $config->current()); | ||
119 | - | ||
120 | - $config->next(); | ||
121 | - $this->assertEquals(2, $config->current()); | ||
122 | - | ||
123 | - foreach ($config as $key => $val) {} | ||
124 | - | ||
125 | - $config->rewind(); | ||
126 | - $this->assertEquals(1, $config->current()); | ||
127 | - } | ||
128 | - | ||
129 | - public function testTransformObjectInArray() { | ||
130 | - $arr = array(6, 3, 3); | ||
131 | - | ||
132 | - $config = new CoreExt_Config($arr); | ||
133 | - | ||
134 | - $this->assertEquals($arr, $config->toArray()); | ||
135 | - } | ||
136 | - | ||
137 | -} | ||
138 | \ No newline at end of file | 0 | \ No newline at end of file |
ieducar/tests/unit/CoreExt_Config_IniTest.class.php
@@ -1,89 +0,0 @@ | @@ -1,89 +0,0 @@ | ||
1 | -<?php | ||
2 | - | ||
3 | -/* | ||
4 | - * i-Educar - Sistema de gestão escolar | ||
5 | - * | ||
6 | - * Copyright (C) 2006 Prefeitura Municipal de Itajaí | ||
7 | - * <ctima@itajai.sc.gov.br> | ||
8 | - * | ||
9 | - * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo | ||
10 | - * sob os termos da Licença Pública Geral GNU conforme publicada pela Free | ||
11 | - * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) | ||
12 | - * qualquer versão posterior. | ||
13 | - * | ||
14 | - * Este programa é distribuído na expectativa de que seja útil, porém, SEM | ||
15 | - * NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU | ||
16 | - * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral | ||
17 | - * do GNU para mais detalhes. | ||
18 | - * | ||
19 | - * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto | ||
20 | - * com este programa; se não, escreva para a Free Software Foundation, Inc., no | ||
21 | - * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | ||
22 | - */ | ||
23 | - | ||
24 | -require_once realpath(dirname(__FILE__) . '/../') . '/UnitBaseTest.class.php'; | ||
25 | -require_once '../lib/CoreExt/Config/Ini.class.php'; | ||
26 | - | ||
27 | - | ||
28 | -/** | ||
29 | - * CoreExt_Config_IniTest class | ||
30 | - * | ||
31 | - * @author Eriksen Costa Paixão <eriksen.paixao_bs@cobra.com.br> | ||
32 | - * @license http://creativecommons.org/licenses/GPL/2.0/legalcode.pt CC GNU GPL | ||
33 | - * @package Test | ||
34 | - * @since Classe disponível desde a versão 1.1.0 | ||
35 | - * @version $Id$ | ||
36 | - */ | ||
37 | -class CoreExt_Config_IniTest extends UnitBaseTest | ||
38 | -{ | ||
39 | - | ||
40 | - public function testParsedIni() { | ||
41 | - $ini = new CoreExt_Config_Ini('../tests/fixtures/configuration/ieducar.ini'); | ||
42 | - $this->assertNotNull($ini->app); | ||
43 | - } | ||
44 | - | ||
45 | - public function testChangeEnviroment() | ||
46 | - { | ||
47 | - $ini = new CoreExt_Config_Ini('../tests/fixtures/configuration/ieducar.ini'); | ||
48 | - $this->assertEquals(FALSE, (bool) $ini->php->display_errors); | ||
49 | - | ||
50 | - $ini->changeEnviroment('development'); | ||
51 | - $this->assertEquals(TRUE, (bool) $ini->php->display_errors); | ||
52 | - | ||
53 | - $ini->changeEnviroment('testing'); | ||
54 | - $this->assertEquals(TRUE, (bool) $ini->php->display_errors); | ||
55 | - | ||
56 | - $ini->changeEnviroment(); | ||
57 | - $this->assertEquals(FALSE, (bool) $ini->php->display_errors); | ||
58 | - } | ||
59 | - | ||
60 | - /** | ||
61 | - * @expectedException Exception | ||
62 | - */ | ||
63 | - public function testInvalidIniFile() { | ||
64 | - // Tentando carregar configuração do blackhole! | ||
65 | - $ini = new CoreExt_Config_Ini('/dev/null'); | ||
66 | - } | ||
67 | - | ||
68 | - /** | ||
69 | - * @expectedException Exception | ||
70 | - */ | ||
71 | - public function testSectionExtendsMoreThanOne() { | ||
72 | - $ini = new CoreExt_Config_Ini('../tests/fixtures/configuration/ieducar-extends-broken.ini'); | ||
73 | - } | ||
74 | - | ||
75 | - /** | ||
76 | - * @expectedException Exception | ||
77 | - */ | ||
78 | - public function testIniSyntaxError() { | ||
79 | - $ini = new CoreExt_Config_Ini('../tests/fixtures/configuration/ieducar-syntax-broken.ini'); | ||
80 | - } | ||
81 | - | ||
82 | - /** | ||
83 | - * @expectedException Exception | ||
84 | - */ | ||
85 | - public function testSectionInheritanceNotExist() { | ||
86 | - $ini = new CoreExt_Config_Ini('../tests/fixtures/configuration/ieducar-inheritance-broken.ini'); | ||
87 | - } | ||
88 | - | ||
89 | -} | ||
90 | \ No newline at end of file | 0 | \ No newline at end of file |
ieducar/tests/unit/FileStreamTest.class.php
@@ -1,157 +0,0 @@ | @@ -1,157 +0,0 @@ | ||
1 | -<?php | ||
2 | - | ||
3 | -/* | ||
4 | - * i-Educar - Sistema de gestão escolar | ||
5 | - * | ||
6 | - * Copyright (C) 2006 Prefeitura Municipal de Itajaí | ||
7 | - * <ctima@itajai.sc.gov.br> | ||
8 | - * | ||
9 | - * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo | ||
10 | - * sob os termos da Licença Pública Geral GNU conforme publicada pela Free | ||
11 | - * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) | ||
12 | - * qualquer versão posterior. | ||
13 | - * | ||
14 | - * Este programa é distribuído na expectativa de que seja útil, porém, SEM | ||
15 | - * NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU | ||
16 | - * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral | ||
17 | - * do GNU para mais detalhes. | ||
18 | - * | ||
19 | - * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto | ||
20 | - * com este programa; se não, escreva para a Free Software Foundation, Inc., no | ||
21 | - * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | ||
22 | - */ | ||
23 | - | ||
24 | -require_once realpath(dirname(__FILE__) . '/../') . '/UnitBaseTest.class.php'; | ||
25 | -require_once 'vfsStream/vfsStream.php'; | ||
26 | -require_once 'Utils/FileStream.class.php'; | ||
27 | -require_once 'Utils/Mimetype.class.php'; | ||
28 | - | ||
29 | - | ||
30 | -/** | ||
31 | - * FileStreamTest class. | ||
32 | - * | ||
33 | - * @author Eriksen Costa Paixão <eriksen.paixao_bs@cobra.com.br> | ||
34 | - * @license http://creativecommons.org/licenses/GPL/2.0/legalcode.pt CC GNU GPL | ||
35 | - * @link http://code.google.com/p/bovigo/wiki/vfsStream vfsStream project | ||
36 | - * @package Test | ||
37 | - * @since Classe disponível desde a versão 1.1.0 | ||
38 | - * @version $Id$ | ||
39 | - */ | ||
40 | -class FileStreamTest extends UnitBaseTest | ||
41 | -{ | ||
42 | - | ||
43 | - protected $Mimetype = NULL; | ||
44 | - | ||
45 | - protected function setUp() { | ||
46 | - $this->Mimetype = new Mimetype(); | ||
47 | - } | ||
48 | - | ||
49 | - protected function configVfs() { | ||
50 | - vfsStreamWrapper::register(); | ||
51 | - vfsStreamWrapper::setRoot(new vfsStreamDirectory('tmp')); | ||
52 | - } | ||
53 | - | ||
54 | - public function testAllowedDirectory() | ||
55 | - { | ||
56 | - $directories = array('pdf', 'tmp'); | ||
57 | - | ||
58 | - $fileStream = new FileStream($this->Mimetype, $directories); | ||
59 | - $this->assertTrue($fileStream->isDirectoryAllowed('pdf')); | ||
60 | - } | ||
61 | - | ||
62 | - public function testDisallowedDirectory() | ||
63 | - { | ||
64 | - $fileStream = new FileStream($this->Mimetype); | ||
65 | - $this->assertFalse($fileStream->isDirectoryAllowed('pdf')); | ||
66 | - } | ||
67 | - | ||
68 | - /** | ||
69 | - * @expectedException Exception | ||
70 | - */ | ||
71 | - public function testSetFileDirectoryDisallowed() | ||
72 | - { | ||
73 | - $filename = 'pdf/example.pdf'; | ||
74 | - $fileStream = new FileStream($this->Mimetype, array('tmp')); | ||
75 | - | ||
76 | - $fileStream->setFilepath($filename); | ||
77 | - } | ||
78 | - | ||
79 | - /** | ||
80 | - * @expectedException Exception | ||
81 | - */ | ||
82 | - public function testSetFileDirectoryAllowed() | ||
83 | - { | ||
84 | - $filename = 'tmp/example.pdf'; | ||
85 | - $fileStream = new FileStream($this->Mimetype, array('tmp')); | ||
86 | - | ||
87 | - $fileStream->setFilepath($filename); | ||
88 | - } | ||
89 | - | ||
90 | - public function testSetFile() | ||
91 | - { | ||
92 | - $this->configVfs(); | ||
93 | - | ||
94 | - // Nome do arquivo | ||
95 | - $filename = 'tmp/example.pdf'; | ||
96 | - | ||
97 | - // Adiciona o schema vfs:// ao caminho do arquivo | ||
98 | - $filepath = vfsStream::url($filename); | ||
99 | - | ||
100 | - // Cria um novo arquivo no vfs | ||
101 | - fopen($filepath, 'a+'); | ||
102 | - | ||
103 | - // Pega o nome do diretório e coloca em array | ||
104 | - $directory = (array) vfsStream::url(vfsStreamWrapper::getRoot()->getName()); | ||
105 | - | ||
106 | - $fileStream = new FileStream($this->Mimetype, $directory); | ||
107 | - $fileStream->setFilepath($filepath); | ||
108 | - } | ||
109 | - | ||
110 | - /** | ||
111 | - * @expectedException Exception | ||
112 | - */ | ||
113 | - public function testStreamFileExtensionNotSupported() | ||
114 | - { | ||
115 | - $this->configVfs(); | ||
116 | - $filename = 'tmp/example.dummy'; | ||
117 | - $filepath = vfsStream::url($filename); | ||
118 | - fopen($filepath, 'a+'); | ||
119 | - $directory = (array) vfsStream::url(vfsStreamWrapper::getRoot()->getName()); | ||
120 | - | ||
121 | - $stub = $this->getMock('Mimetype'); | ||
122 | - $stub->expects($this->once()) | ||
123 | - ->method('getType') | ||
124 | - ->will($this->returnValue(FALSE)); | ||
125 | - | ||
126 | - $fileStream = new FileStream($stub, $directory); | ||
127 | - $fileStream->setFilepath($filepath); | ||
128 | - | ||
129 | - $fileStream->streamFile(); | ||
130 | - } | ||
131 | - | ||
132 | - /** | ||
133 | - * Tag disponível apenas no PHPUnit 3.4, ainda não disponível no pacote | ||
134 | - * Pear PHPUnit-beta3. Note o uso do '@' para supressão das mensagens de | ||
135 | - * erro. | ||
136 | - * | ||
137 | - * @outputBuffering enabled | ||
138 | - */ | ||
139 | - public function testStreamFileExtensionSupported() | ||
140 | - { | ||
141 | - $this->configVfs(); | ||
142 | - $filename = 'tmp/example.pdf'; | ||
143 | - $filepath = vfsStream::url($filename); | ||
144 | - fopen($filepath, 'a+'); | ||
145 | - $directory = (array) vfsStream::url(vfsStreamWrapper::getRoot()->getName()); | ||
146 | - | ||
147 | - $stub = $this->getMock('Mimetype'); | ||
148 | - $stub->expects($this->once()) | ||
149 | - ->method('getType') | ||
150 | - ->will($this->returnValue('application/pdf')); | ||
151 | - | ||
152 | - $fileStream = new FileStream($stub, $directory); | ||
153 | - $fileStream->setFilepath($filepath); | ||
154 | - @$fileStream->streamFile(); | ||
155 | - } | ||
156 | - | ||
157 | -} |
@@ -0,0 +1,55 @@ | @@ -0,0 +1,55 @@ | ||
1 | +<?php | ||
2 | + | ||
3 | +/** | ||
4 | + * i-Educar - Sistema de gestão escolar | ||
5 | + * | ||
6 | + * Copyright (C) 2006 Prefeitura Municipal de Itajaí | ||
7 | + * <ctima@itajai.sc.gov.br> | ||
8 | + * | ||
9 | + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo | ||
10 | + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free | ||
11 | + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) | ||
12 | + * qualquer versão posterior. | ||
13 | + * | ||
14 | + * Este programa é distribuído na expectativa de que seja útil, porém, SEM | ||
15 | + * NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU | ||
16 | + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral | ||
17 | + * do GNU para mais detalhes. | ||
18 | + * | ||
19 | + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto | ||
20 | + * com este programa; se não, escreva para a Free Software Foundation, Inc., no | ||
21 | + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | ||
22 | + * | ||
23 | + * @author Eriksen Costa Paixão <eriksen.paixao_bs@cobra.com.br> | ||
24 | + * @category i-Educar | ||
25 | + * @license @@license@@ | ||
26 | + * @package Utils | ||
27 | + * @subpackage UnitTests | ||
28 | + * @since Arquivo disponível desde a versão 1.1.0 | ||
29 | + * @version $Id$ | ||
30 | + */ | ||
31 | + | ||
32 | +/** | ||
33 | + * Utils_AllTests class. | ||
34 | + * | ||
35 | + * Arquivo de definição de suíte para o pacote Utils. | ||
36 | + * | ||
37 | + * @author Eriksen Costa Paixão <eriksen.paixao_bs@cobra.com.br> | ||
38 | + * @category i-Educar | ||
39 | + * @license @@license@@ | ||
40 | + * @package Utils | ||
41 | + * @subpackage UnitTests | ||
42 | + * @since Classe disponível desde a versão 1.1.0 | ||
43 | + * @version @@package_version@@ | ||
44 | + */ | ||
45 | +class Utils_AllTests extends TestCollector | ||
46 | +{ | ||
47 | + protected $_name = 'Suíte de testes unitários de Utils (pacote de transição)'; | ||
48 | + protected $_file = __FILE__; | ||
49 | + | ||
50 | + public static function suite() | ||
51 | + { | ||
52 | + $instance = new self; | ||
53 | + return $instance->addDirectoryTests(); | ||
54 | + } | ||
55 | +} | ||
0 | \ No newline at end of file | 56 | \ No newline at end of file |
@@ -0,0 +1,164 @@ | @@ -0,0 +1,164 @@ | ||
1 | +<?php | ||
2 | + | ||
3 | +/* | ||
4 | + * i-Educar - Sistema de gestão escolar | ||
5 | + * | ||
6 | + * Copyright (C) 2006 Prefeitura Municipal de Itajaí | ||
7 | + * <ctima@itajai.sc.gov.br> | ||
8 | + * | ||
9 | + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo | ||
10 | + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free | ||
11 | + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) | ||
12 | + * qualquer versão posterior. | ||
13 | + * | ||
14 | + * Este programa é distribuído na expectativa de que seja útil, porém, SEM | ||
15 | + * NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU | ||
16 | + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral | ||
17 | + * do GNU para mais detalhes. | ||
18 | + * | ||
19 | + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto | ||
20 | + * com este programa; se não, escreva para a Free Software Foundation, Inc., no | ||
21 | + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | ||
22 | + * | ||
23 | + * @author Eriksen Costa Paixão <eriksen.paixao_bs@cobra.com.br> | ||
24 | + * @category i-Educar | ||
25 | + * @license @@license@@ | ||
26 | + * @package Utils | ||
27 | + * @subpackage UnitTests | ||
28 | + * @since Arquivo disponível desde a versão 1.1.0 | ||
29 | + * @version $Id$ | ||
30 | + */ | ||
31 | + | ||
32 | +require_once 'UnitBaseTest.class.php'; | ||
33 | +require_once 'vfsStream/vfsStream.php'; | ||
34 | +require_once 'Utils/FileStream.class.php'; | ||
35 | +require_once 'Utils/Mimetype.class.php'; | ||
36 | + | ||
37 | + | ||
38 | +/** | ||
39 | + * FileStreamTest class. | ||
40 | + * | ||
41 | + * @author Eriksen Costa Paixão <eriksen.paixao_bs@cobra.com.br> | ||
42 | + * @category i-Educar | ||
43 | + * @license @@license@@ | ||
44 | + * @package Utils | ||
45 | + * @subpackage UnitTests | ||
46 | + * @since Classe disponível desde a versão 1.1.0 | ||
47 | + * @version @@package_version@@ | ||
48 | + */ | ||
49 | +class FileStreamTest extends UnitBaseTest | ||
50 | +{ | ||
51 | + protected $Mimetype = NULL; | ||
52 | + | ||
53 | + protected function setUp() | ||
54 | + { | ||
55 | + $this->Mimetype = new Mimetype(); | ||
56 | + } | ||
57 | + | ||
58 | + protected function configVfs() | ||
59 | + { | ||
60 | + vfsStreamWrapper::register(); | ||
61 | + vfsStreamWrapper::setRoot(new vfsStreamDirectory('tmp')); | ||
62 | + } | ||
63 | + | ||
64 | + public function testAllowedDirectory() | ||
65 | + { | ||
66 | + $directories = array('pdf', 'tmp'); | ||
67 | + | ||
68 | + $fileStream = new FileStream($this->Mimetype, $directories); | ||
69 | + $this->assertTrue($fileStream->isDirectoryAllowed('pdf')); | ||
70 | + } | ||
71 | + | ||
72 | + public function testDisallowedDirectory() | ||
73 | + { | ||
74 | + $fileStream = new FileStream($this->Mimetype); | ||
75 | + $this->assertFalse($fileStream->isDirectoryAllowed('pdf')); | ||
76 | + } | ||
77 | + | ||
78 | + /** | ||
79 | + * @expectedException Exception | ||
80 | + */ | ||
81 | + public function testSetFileDirectoryDisallowed() | ||
82 | + { | ||
83 | + $filename = 'pdf/example.pdf'; | ||
84 | + $fileStream = new FileStream($this->Mimetype, array('tmp')); | ||
85 | + $fileStream->setFilepath($filename); | ||
86 | + } | ||
87 | + | ||
88 | + /** | ||
89 | + * @expectedException Exception | ||
90 | + */ | ||
91 | + public function testSetFileDirectoryAllowed() | ||
92 | + { | ||
93 | + $filename = 'tmp/example.pdf'; | ||
94 | + $fileStream = new FileStream($this->Mimetype, array('tmp')); | ||
95 | + $fileStream->setFilepath($filename); | ||
96 | + } | ||
97 | + | ||
98 | + public function testSetFile() | ||
99 | + { | ||
100 | + $this->configVfs(); | ||
101 | + | ||
102 | + // Nome do arquivo | ||
103 | + $filename = 'tmp/example.pdf'; | ||
104 | + | ||
105 | + // Adiciona o schema vfs:// ao caminho do arquivo | ||
106 | + $filepath = vfsStream::url($filename); | ||
107 | + | ||
108 | + // Cria um novo arquivo no vfs | ||
109 | + fopen($filepath, 'a+'); | ||
110 | + | ||
111 | + // Pega o nome do diretório e coloca em array | ||
112 | + $directory = (array) vfsStream::url(vfsStreamWrapper::getRoot()->getName()); | ||
113 | + | ||
114 | + $fileStream = new FileStream($this->Mimetype, $directory); | ||
115 | + $fileStream->setFilepath($filepath); | ||
116 | + } | ||
117 | + | ||
118 | + /** | ||
119 | + * @expectedException Exception | ||
120 | + */ | ||
121 | + public function testStreamFileExtensionNotSupported() | ||
122 | + { | ||
123 | + $this->configVfs(); | ||
124 | + $filename = 'tmp/example.dummy'; | ||
125 | + $filepath = vfsStream::url($filename); | ||
126 | + fopen($filepath, 'a+'); | ||
127 | + $directory = (array) vfsStream::url(vfsStreamWrapper::getRoot()->getName()); | ||
128 | + | ||
129 | + $stub = $this->getMock('Mimetype'); | ||
130 | + $stub->expects($this->once()) | ||
131 | + ->method('getType') | ||
132 | + ->will($this->returnValue(FALSE)); | ||
133 | + | ||
134 | + $fileStream = new FileStream($stub, $directory); | ||
135 | + $fileStream->setFilepath($filepath); | ||
136 | + | ||
137 | + $fileStream->streamFile(); | ||
138 | + } | ||
139 | + | ||
140 | + /** | ||
141 | + * Tag disponível apenas no PHPUnit 3.4, ainda não disponível no pacote | ||
142 | + * Pear PHPUnit-beta3. Note o uso do '@' para supressão das mensagens de | ||
143 | + * erro. | ||
144 | + * | ||
145 | + * @outputBuffering enabled | ||
146 | + */ | ||
147 | + public function testStreamFileExtensionSupported() | ||
148 | + { | ||
149 | + $this->configVfs(); | ||
150 | + $filename = 'tmp/example.pdf'; | ||
151 | + $filepath = vfsStream::url($filename); | ||
152 | + fopen($filepath, 'a+'); | ||
153 | + $directory = (array) vfsStream::url(vfsStreamWrapper::getRoot()->getName()); | ||
154 | + | ||
155 | + $stub = $this->getMock('Mimetype'); | ||
156 | + $stub->expects($this->once()) | ||
157 | + ->method('getType') | ||
158 | + ->will($this->returnValue('application/pdf')); | ||
159 | + | ||
160 | + $fileStream = new FileStream($stub, $directory); | ||
161 | + $fileStream->setFilepath($filepath); | ||
162 | + @$fileStream->streamFile(); | ||
163 | + } | ||
164 | +} | ||
0 | \ No newline at end of file | 165 | \ No newline at end of file |