From 269ca229bad86ad4d25efd514e55271191e4cdee Mon Sep 17 00:00:00 2001 From: Eriksen Costa Paixão Date: Fri, 24 Apr 2009 23:54:11 +0000 Subject: [PATCH] #21 by Eriksen: Corrigido bug que impedia apagar uma categoria de servidor do banco de dados. --- ieducar/intranet/educar_categoria_nivel_lst.php | 329 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------------------------------------------------------------------------------------------------------------------------------------- ieducar/tests/functional/ServidorCategoriaNivelWebTest.class.php | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 225 insertions(+), 155 deletions(-) create mode 100644 ieducar/tests/functional/ServidorCategoriaNivelWebTest.class.php diff --git a/ieducar/intranet/educar_categoria_nivel_lst.php b/ieducar/intranet/educar_categoria_nivel_lst.php index 68afe9b..24ed276 100644 --- a/ieducar/intranet/educar_categoria_nivel_lst.php +++ b/ieducar/intranet/educar_categoria_nivel_lst.php @@ -1,162 +1,181 @@ SetTitulo( "Prefeitura de Itajaí - Listagem Categoria Nível" ); - $this->processoAp = "829"; - } +/** + * + * @author Prefeitura Municipal de Itajaí + * @version SVN: $Id$ + * + * Pacote: i-PLB Software Público Livre e Brasileiro + * + * Copyright (C) 2006 PMI - Prefeitura Municipal de Itajaí + * ctima@itajai.sc.gov.br + * + * Este programa é software livre, você pode redistribuí-lo e/ou + * modificá-lo sob os termos da Licença Pública Geral GNU, conforme + * publicada pela Free Software Foundation, tanto a versão 2 da + * Licença como (a seu critério) qualquer versão mais nova. + * + * Este programa é distribuído na expectativa de ser útil, mas SEM + * QUALQUER GARANTIA. Sem mesmo a garantia implícita de COMERCIALI- + * ZAÇÃO ou de ADEQUAÇÃO A QUALQUER PROPÓSITO EM PARTICULAR. Con- + * sulte a Licença Pública Geral GNU para obter mais detalhes. + * + * Você deve ter recebido uma cópia da Licença Pública Geral GNU + * junto com este programa. Se não, escreva para a Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + * 02111-1307, USA. + * + */ + +require_once 'include/clsBase.inc.php'; +require_once 'include/clsListagem.inc.php'; +require_once 'include/clsBanco.inc.php'; +require_once 'include/pmieducar/geral.inc.php'; + + + +class clsIndexBase extends clsBase { + public function Formular() { + $this->SetTitulo("Prefeitura de Itajaí - Listagem Categoria Nível"); + $this->processoAp = "829"; + } } -class indice extends clsListagem -{ - /** - * Referencia pega da session para o idpes do usuario atual - * - * @var int - */ - var $__pessoa_logada; - - /** - * Titulo no topo da pagina - * - * @var int - */ - var $__titulo; - - /** - * Quantidade de registros a ser apresentada em cada pagina - * - * @var int - */ - var $__limite; - - /** - * Inicio dos registros a serem exibidos (limit) - * - * @var int - */ - var $__offset; - - var $cod_categoria_nivel; - var $ref_usuario_exc; - var $ref_usuario_cad; - var $nm_categoria_nivel; - var $data_cadastro; - var $data_exclusao; - var $ativo; - - function Gerar() - { - @session_start(); - $this->__pessoa_logada = $_SESSION['id_pessoa']; - session_write_close(); - - $this->__titulo = "Categoria Nivel - Listagem"; - - foreach( $_GET AS $var => $val ) // passa todos os valores obtidos no GET para atributos do objeto - $this->$var = ( $val === "" ) ? null: $val; - - $this->addBanner( "http://ieducar.dccobra.com.br/intranet/imagens/nvp_top_intranet.jpg", "http://ieducar.dccobra.com.br/intranet/imagens/nvp_vert_intranet.jpg", "Intranet" ); - - $this->addCabecalhos( array( - //"Categoria Nivel", - "Nome Categoria Nivel" - ) ); - - // Filtros de Foreign Keys - - - // outros Filtros - $this->campoTexto( "nm_categoria_nivel", "Nome Categoria Nivel", $this->nm_categoria_nivel, 30, 255, false ); - - - // Paginador - $this->__limite = 20; - $this->__offset = ( $_GET["pagina_{$this->nome}"] ) ? $_GET["pagina_{$this->nome}"]*$this->__limite-$this->__limite: 0; - - $obj_categoria_nivel = new clsPmieducarCategoriaNivel(); - $obj_categoria_nivel->setOrderby( "nm_categoria_nivel ASC" ); - $obj_categoria_nivel->setLimite( $this->__limite, $this->__offset ); - - $lista = $obj_categoria_nivel->lista( - null, - null, - $this->nm_categoria_nivel, - null, - null, - 1 - ); - - $total = $obj_categoria_nivel->_total; - - // monta a lista - if( is_array( $lista ) && count( $lista ) ) - { - foreach ( $lista AS $registro ) - { - // muda os campos data - $registro["data_cadastro_time"] = strtotime( substr( $registro["data_cadastro"], 0, 16 ) ); - $registro["data_cadastro_br"] = date( "d/m/Y H:i", $registro["data_cadastro_time"] ); - - $registro["data_exclusao_time"] = strtotime( substr( $registro["data_exclusao"], 0, 16 ) ); - $registro["data_exclusao_br"] = date( "d/m/Y H:i", $registro["data_exclusao_time"] ); - - - // pega detalhes de foreign_keys - if( class_exists( "clsPmieducarUsuario" ) ) - { - $obj_ref_usuario_cad = new clsPmieducarUsuario( $registro["ref_usuario_cad"] ); - $det_ref_usuario_cad = $obj_ref_usuario_cad->detalhe(); - $registro["ref_usuario_cad"] = $det_ref_usuario_cad["data_cadastro"]; - } - else - { - $registro["ref_usuario_cad"] = "Erro na geracao"; - echo ""; - } - - if( class_exists( "clsPmieducarUsuario" ) ) - { - $obj_ref_usuario_exc = new clsPmieducarUsuario( $registro["ref_usuario_exc"] ); - $det_ref_usuario_exc = $obj_ref_usuario_exc->detalhe(); - $registro["ref_usuario_exc"] = $det_ref_usuario_exc["data_cadastro"]; - } - else - { - $registro["ref_usuario_exc"] = "Erro na geracao"; - echo ""; - } - - - $this->addLinhas( array( - //"{$registro["cod_categoria_nivel"]}", - "{$registro["nm_categoria_nivel"]}" - ) ); - } - } - $this->addPaginador2( "educar_categoria_nivel_lst.php", $total, $_GET, $this->nome, $this->__limite ); - $obj_permissoes = new clsPermissoes(); - if( $obj_permissoes->permissao_cadastra( 829, $this->__pessoa_logada, 3, null, true ) ) - { - $this->acao = "go(\"educar_categoria_nivel_cad.php\")"; - $this->nome_acao = "Novo"; - } - - $this->largura = "100%"; - } + + +class indice extends clsListagem { + /** + * Referencia pega da session para o idpes do usuario atual + * + * @var int + */ + var $__pessoa_logada; + + /** + * Titulo no topo da pagina + * + * @var int + */ + var $__titulo; + + /** + * Quantidade de registros a ser apresentada em cada pagina + * + * @var int + */ + var $__limite; + + /** + * Inicio dos registros a serem exibidos (limit) + * + * @var int + */ + var $__offset; + + var $cod_categoria_nivel; + var $ref_usuario_exc; + var $ref_usuario_cad; + var $nm_categoria_nivel; + var $data_cadastro; + var $data_exclusao; + var $ativo; + + public function Gerar() { + session_start(); + $this->__pessoa_logada = $_SESSION['id_pessoa']; + session_write_close(); + + $this->__titulo = 'Categoria Nivel - Listagem'; + + // passa todos os valores obtidos no GET para atributos do objeto + foreach ($_GET as $var => $val) { + $this->$var = ($val === "") ? NULL : $val; + } + + $this->addBanner('http://ieducar.dccobra.com.br/intranet/imagens/nvp_top_intranet.jpg", "http://ieducar.dccobra.com.br/intranet/imagens/nvp_vert_intranet.jpg', 'Intranet'); + + $this->addCabecalhos(array( + 'Nome Categoria Nivel' + )); + + // Filtros + $this->campoTexto('nm_categoria_nivel', 'Nome Categoria Nivel', + $this->nm_categoria_nivel, 30, 255, FALSE); + + // Paginador + $this->__limite = 20; + $this->__offset = ($_GET['pagina_' . $this->nome]) ? + $_GET['pagina_' . $this->nome] * $this->__limite-$this->__limite : 0; + + $obj_categoria_nivel = new clsPmieducarCategoriaNivel(); + $obj_categoria_nivel->setOrderby('nm_categoria_nivel ASC'); + $obj_categoria_nivel->setLimite($this->__limite, $this->__offset); + + $lista = $obj_categoria_nivel->lista( + NULL, NULL, $this->nm_categoria_nivel, NULL, NULL, NULL, NULL, NULL, 1 + ); + + $total = $obj_categoria_nivel->_total; + + // Monta a lista + if (is_array($lista) && count($lista)) { + foreach ($lista as $registro) { + // muda os campos data + $registro['data_cadastro_time'] = strtotime( substr( $registro['data_cadastro'], 0, 16)); + $registro['data_cadastro_br'] = date('d/m/Y H:i', $registro['data_cadastro_time']); + + $registro['data_exclusao_time'] = strtotime(substr( $registro['data_exclusao'], 0, 16)); + $registro['data_exclusao_br'] = date('d/m/Y H:i', $registro['data_exclusao_time']); + + // pega detalhes de foreign_keys + if (class_exists('clsPmieducarUsuario')) { + $obj_ref_usuario_cad = new clsPmieducarUsuario($registro['ref_usuario_cad']); + $det_ref_usuario_cad = $obj_ref_usuario_cad->detalhe(); + $registro['ref_usuario_cad'] = $det_ref_usuario_cad['data_cadastro']; + } + else { + $registro['ref_usuario_cad'] = 'Erro na geracao'; + } + + if (class_exists('clsPmieducarUsuario')) { + $obj_ref_usuario_exc = new clsPmieducarUsuario( $registro['ref_usuario_exc']); + $det_ref_usuario_exc = $obj_ref_usuario_exc->detalhe(); + $registro['ref_usuario_exc'] = $det_ref_usuario_exc['data_cadastro']; + } + else { + $registro['ref_usuario_exc'] = 'Erro na geracao'; + } + + $this->addLinhas(array( + sprintf('%s', + $registro['cod_categoria_nivel'], $registro['nm_categoria_nivel']) + )); + } + } + + $this->addPaginador2('educar_categoria_nivel_lst.php', $total, $_GET, + $this->nome, $this->__limite); + + $obj_permissoes = new clsPermissoes(); + if ($obj_permissoes->permissao_cadastra(829, $this->__pessoa_logada, 3, + NULL, TRUE)) { + $this->acao = 'go("educar_categoria_nivel_cad.php")'; + $this->nome_acao = 'Novo'; + } + + $this->largura = '100%'; + } } -// cria uma extensao da classe base + + + +// Instancia a classe da página $pagina = new clsIndexBase(); -// cria o conteudo + +// Instancia o conteúdo $miolo = new indice(); -// adiciona o conteudo na clsBase + +// Passa o conteúdo para a classe da página $pagina->addForm( $miolo ); -// gera o html -$pagina->MakeAll(); -?> + +// Imprime o HTML +$pagina->MakeAll(); \ No newline at end of file diff --git a/ieducar/tests/functional/ServidorCategoriaNivelWebTest.class.php b/ieducar/tests/functional/ServidorCategoriaNivelWebTest.class.php new file mode 100644 index 0000000..21ded85 --- /dev/null +++ b/ieducar/tests/functional/ServidorCategoriaNivelWebTest.class.php @@ -0,0 +1,51 @@ + + * @since 1.0.1 + * @version SVN: $Id$ + */ + +require_once realpath(dirname(__FILE__) . '/../') . '/FunctionalBaseTest.class.php'; + +class ServidorCategoriaNivelWebTest extends FunctionalBaseTest { + + private $slStringTest = 'Selenese Nivel Teste'; + + protected function tearDown() { + require_once 'include/pmieducar/clsPmieducarCategoriaNivel.inc.php'; + + $db = new clsBanco(); + $categoriaNivel = new clsPmieducarCategoriaNivel(); + $sql = sprintf('DELETE FROM %s WHERE %s = \'%s\'', + $categoriaNivel->_tabela, 'nm_categoria_nivel', $this->slStringTest); + + $db->Consulta($sql); + } + + private function createNewEntry() { + $this->open("/intranet/educar_categoria_nivel_lst.php"); + $this->clickAndWait("//input[@value=' Novo ']"); + $this->type("nm_categoria_nivel", $this->slStringTest); + $this->clickAndWait("btn_enviar"); + } + + public function testCategoriaNivelDelete() { + $this->doLogin(); + $this->createNewEntry(); + + $this->clickAndWait("link=" . $this->slStringTest); + $this->clickAndWait("//input[@value=' Editar ']"); + $this->clickAndWait("//input[@value=' Excluir ']"); + $this->assertTrue((bool) preg_match('/^Excluir registro[\s\S]$/', $this->getConfirmation())); + $this->assertTrue(!$this->isTextPresent($this->slStringTest)); + } +} \ No newline at end of file -- libgit2 0.21.2