Commit 2e6177c887e6267fdfffbb735bdd65b8fe6a89aa
Exists in
master
Merge branch 'devel-unb' of https://github.com/i-educar-unb/ieducar into devel-unb
Showing
13 changed files
with
95 additions
and
697 deletions
Show diff stats
.gitignore
ieducar/intranet/atendidos_cad.php
... | ... | @@ -574,7 +574,7 @@ class indice extends clsCadastro |
574 | 574 | |
575 | 575 | // naturalidade |
576 | 576 | |
577 | - $options = array('label' => 'Naturalidade', 'required' => false); | |
577 | + $options = array('label' => 'Naturalidade', 'required' => true); | |
578 | 578 | |
579 | 579 | $helperOptions = array('objectName' => 'naturalidade', |
580 | 580 | 'hiddenInputOptions' => array('options' => array('value' => $this->naturalidade_id))); | ... | ... |
ieducar/intranet/educar_acervo_cad.php
... | ... | @@ -395,7 +395,7 @@ class indice extends clsCadastro |
395 | 395 | $this->campoNumero( "num_edicao", "Número Edicão", $this->num_edicao, 20, 255, true ); |
396 | 396 | $this->campoNumero( "ano", "Ano", $this->ano, 5, 4, true ); |
397 | 397 | $this->campoNumero( "num_paginas", "Número Páginas", $this->num_paginas, 5, 255, true ); |
398 | - $this->campoNumero( "isbn", "ISBN", $this->isbn, 20, 13, true ); | |
398 | + $this->campoNumero( "isbn", "ISBN", $this->isbn, 20, 13, false ); | |
399 | 399 | } |
400 | 400 | |
401 | 401 | function Novo() | ... | ... |
ieducar/intranet/educar_acervo_colecao_cad.php
... | ... | @@ -79,6 +79,16 @@ class indice extends clsCadastro |
79 | 79 | foreach( $registro AS $campo => $val ) // passa todos os valores obtidos no registro para atributos do objeto |
80 | 80 | $this->$campo = $val; |
81 | 81 | |
82 | + $obj_obra = new clsPmieducarAcervoColecao($this->cod_acervo_colecao); | |
83 | + $det_obra = $obj_obra->detalhe(); | |
84 | + | |
85 | + $obj_biblioteca = new clsPmieducarBiblioteca($det_obra["ref_cod_biblioteca"]); | |
86 | + $obj_det = $obj_biblioteca->detalhe(); | |
87 | + | |
88 | + $this->ref_cod_instituicao = $obj_det["ref_cod_instituicao"]; | |
89 | + $this->ref_cod_escola = $obj_det["ref_cod_escola"]; | |
90 | + $this->ref_cod_biblioteca = $obj_det["cod_biblioteca"]; | |
91 | + | |
82 | 92 | $obj_permissoes = new clsPermissoes(); |
83 | 93 | if( $obj_permissoes->permissao_excluir( 593, $this->pessoa_logada, 11 ) ) |
84 | 94 | { | ... | ... |
ieducar/intranet/educar_acervo_colecao_det.php
... | ... | @@ -69,17 +69,82 @@ class indice extends clsDetalhe |
69 | 69 | |
70 | 70 | $tmp_obj = new clsPmieducarAcervoColecao( $this->cod_acervo_colecao ); |
71 | 71 | $registro = $tmp_obj->detalhe(); |
72 | + | |
73 | + if( class_exists( "clsPmieducarBiblioteca" ) ) | |
74 | + { | |
75 | + $obj_ref_cod_biblioteca = new clsPmieducarBiblioteca( $registro["ref_cod_biblioteca"] ); | |
76 | + $det_ref_cod_biblioteca = $obj_ref_cod_biblioteca->detalhe(); | |
77 | + $registro["ref_cod_biblioteca"] = $det_ref_cod_biblioteca["nm_biblioteca"]; | |
78 | + if( class_exists( "clsPmieducarInstituicao" ) ) | |
79 | + { | |
80 | + $registro["ref_cod_instituicao"] = $det_ref_cod_biblioteca["ref_cod_instituicao"]; | |
81 | + $obj_ref_cod_instituicao = new clsPmieducarInstituicao( $registro["ref_cod_instituicao"] ); | |
82 | + $det_ref_cod_instituicao = $obj_ref_cod_instituicao->detalhe(); | |
83 | + $registro["ref_cod_instituicao"] = $det_ref_cod_instituicao["nm_instituicao"]; | |
84 | + } | |
85 | + else | |
86 | + { | |
87 | + $registro["ref_cod_instituicao"] = "Erro na geracao"; | |
88 | + echo "<!--\nErro\nClasse nao existente: clsPmieducarInstituicao\n-->"; | |
89 | + } | |
90 | + } | |
91 | + | |
92 | + if( class_exists( "clsPmieducarEscola" ) ) | |
93 | + { | |
94 | + $registro["ref_cod_escola"] = $det_ref_cod_biblioteca["ref_cod_escola"]; | |
95 | + $obj_ref_cod_escola = new clsPmieducarEscola( $registro["ref_cod_escola"] ); | |
96 | + $det_ref_cod_escola = $obj_ref_cod_escola->detalhe(); | |
97 | + $idpes = $det_ref_cod_escola["ref_idpes"]; | |
98 | + if ($idpes) | |
99 | + { | |
100 | + $obj_escola = new clsPessoaJuridica( $idpes ); | |
101 | + $obj_escola_det = $obj_escola->detalhe(); | |
102 | + $registro["ref_cod_escola"] = $obj_escola_det["fantasia"]; | |
103 | + } | |
104 | + else | |
105 | + { | |
106 | + $obj_escola = new clsPmieducarEscolaComplemento( $registro["ref_cod_escola"] ); | |
107 | + $obj_escola_det = $obj_escola->detalhe(); | |
108 | + $registro["ref_cod_escola"] = $obj_escola_det["nm_escola"]; | |
109 | + } | |
110 | + } | |
111 | + | |
112 | + $obj_permissoes = new clsPermissoes(); | |
113 | + $nivel_usuario = $obj_permissoes->nivel_acesso($this->pessoa_logada); | |
114 | + | |
72 | 115 | |
73 | 116 | if( ! $registro ) |
74 | 117 | { |
75 | 118 | header( "location: educar_acervo_colecao_lst.php" ); |
76 | 119 | die(); |
77 | 120 | } |
121 | + | |
122 | + if ($nivel_usuario == 1) | |
123 | + { | |
124 | + if( $registro["ref_cod_instituicao"] ) | |
125 | + { | |
126 | + $this->addDetalhe( array( "Instituição", "{$registro["ref_cod_instituicao"]}") ); | |
127 | + } | |
128 | + } | |
129 | + | |
130 | + if ($nivel_usuario == 1 || $nivel_usuario == 2) | |
131 | + { | |
132 | + if( $registro["ref_cod_escola"] ) | |
133 | + { | |
134 | + $this->addDetalhe( array( "Escola", "{$registro["ref_cod_escola"]}") ); | |
135 | + } | |
136 | + } | |
78 | 137 | |
138 | + if( $registro["ref_cod_biblioteca"] ) | |
139 | + { | |
140 | + $this->addDetalhe( array( "Biblioteca", "{$registro["ref_cod_biblioteca"]}") ); | |
141 | + } | |
142 | + | |
79 | 143 | if( $registro["cod_acervo_colecao"] ) |
80 | 144 | { |
81 | 145 | $this->addDetalhe( array( "Código Coleção", "{$registro["cod_acervo_colecao"]}") ); |
82 | 146 | } |
147 | + | |
83 | 148 | if( $registro["nm_colecao"] ) |
84 | 149 | { |
85 | 150 | $this->addDetalhe( array( "Coleção", "{$registro["nm_colecao"]}") ); |
... | ... | @@ -88,6 +153,7 @@ class indice extends clsDetalhe |
88 | 153 | { |
89 | 154 | $this->addDetalhe( array( "Descrição", "{$registro["descricao"]}") ); |
90 | 155 | } |
156 | + | |
91 | 157 | |
92 | 158 | $obj_permissoes = new clsPermissoes(); |
93 | 159 | if( $obj_permissoes->permissao_cadastra( 593, $this->pessoa_logada, 11 ) ) | ... | ... |
ieducar/intranet/include/clsBase.inc.php
... | ... | @@ -29,7 +29,8 @@ |
29 | 29 | */ |
30 | 30 | |
31 | 31 | // Inclui arquivo de bootstrapping |
32 | -require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/bootstrap.php'; | |
32 | +//require_once '/home/rafael/ieducar/ieducar/includes/bootstrap.php'; | |
33 | +require_once '../includes/bootstrap.php'; | |
33 | 34 | |
34 | 35 | // redireciona requisições, caso configurado |
35 | 36 | if ($GLOBALS['coreExt']['Config']->app->routes && | ... | ... |
ieducar/intranet/include/pmieducar/clsPmieducarAcervo.inc.php
... | ... | @@ -422,7 +422,7 @@ class clsPmieducarAcervo |
422 | 422 | */ |
423 | 423 | function cadastra() |
424 | 424 | { |
425 | - if( is_numeric( $this->ref_cod_exemplar_tipo ) && is_numeric( $this->ref_usuario_cad ) && is_numeric( $this->ref_cod_acervo_idioma ) && is_numeric( $this->ref_cod_acervo_editora ) && is_string( $this->titulo ) && is_numeric( $this->volume ) && is_numeric( $this->num_edicao ) && is_numeric( $this->ano ) && is_numeric( $this->num_paginas ) && is_numeric( $this->isbn ) && is_numeric( $this->ref_cod_biblioteca ) ) | |
425 | + if( is_numeric( $this->ref_cod_exemplar_tipo ) && is_numeric( $this->ref_usuario_cad ) && is_numeric( $this->ref_cod_acervo_idioma ) && is_numeric( $this->ref_cod_acervo_editora ) && is_string( $this->titulo ) && is_numeric( $this->volume ) && is_numeric( $this->num_edicao ) && is_numeric( $this->ano ) && is_numeric( $this->num_paginas ) && is_numeric( $this->ref_cod_biblioteca ) ) | |
426 | 426 | { |
427 | 427 | $db = new clsBanco(); |
428 | 428 | ... | ... |
ieducar/intranet/include/pmieducar/clsPmieducarExemplar.inc.php
... | ... | @@ -395,13 +395,22 @@ class clsPmieducarExemplar |
395 | 395 | $campos .= "{$gruda}ativo"; |
396 | 396 | $valores .= "{$gruda}'1'"; |
397 | 397 | $gruda = ", "; |
398 | - if( is_string( $this->data_aquisicao ) ) | |
398 | + | |
399 | + if( is_string( $this->data_aquisicao ) ) | |
399 | 400 | { |
400 | 401 | $campos .= "{$gruda}data_aquisicao"; |
401 | 402 | $valores .= "{$gruda}'{$this->data_aquisicao}'"; |
402 | 403 | $gruda = ", "; |
403 | 404 | } |
404 | - | |
405 | + | |
406 | + if($this->tombo != NULL){ | |
407 | + $sql = "SELECT * FROM pmieducar.exemplar WHERE tombo = {$this->tombo}"; | |
408 | + $consulta = new clsBanco(); | |
409 | + $tombo = $consulta->CampoUnico($sql); | |
410 | + if($tombo != NULL){ | |
411 | + return false; | |
412 | + } | |
413 | + } | |
405 | 414 | |
406 | 415 | $db->Consulta( "INSERT INTO {$this->_tabela} ( $campos ) VALUES( $valores )" ); |
407 | 416 | return $db->InsertId( "{$this->_tabela}_cod_exemplar_seq"); | ... | ... |
ieducar/tests/unit/App/Model/IedFinderTest.php
... | ... | @@ -207,10 +207,11 @@ class App_Model_IedFinderTest extends UnitBaseTest |
207 | 207 | ); |
208 | 208 | |
209 | 209 | $mock = $this->getCleanMock('clsPmieducarSerie'); |
210 | + | |
210 | 211 | $mock->expects($this->exactly(2)) |
211 | 212 | ->method('lista') |
212 | 213 | ->will($this->onConsecutiveCalls($returnValue, array($returnValue[1]))); |
213 | - | |
214 | + | |
214 | 215 | // Registra a instância no repositório de classes de CoreExt_Entity |
215 | 216 | $instance = CoreExt_Entity::addClassToStorage( |
216 | 217 | 'clsPmieducarSerie', $mock, NULL, TRUE); | ... | ... |
ieducar/tests/unit/CoreExt/DataMapper/IntegrationCompoundPkeyTest.php
... | ... | @@ -1,155 +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 | - * @category i-Educar | |
25 | - * @license @@license@@ | |
26 | - * @package CoreExt_DataMapper | |
27 | - * @subpackage IntegrationTests | |
28 | - * @since Arquivo disponível desde a versão 1.1.0 | |
29 | - * @version $Id$ | |
30 | - */ | |
31 | - | |
32 | -require_once 'CoreExt/_stub/EntityCompoundDataMapper.php'; | |
33 | - | |
34 | -/** | |
35 | - * CoreExt_DataMapper_IntegrationCompoundPkeyTest class. | |
36 | - * | |
37 | - * @author Eriksen Costa Paixão <eriksen.paixao_bs@cobra.com.br> | |
38 | - * @category i-Educar | |
39 | - * @license @@license@@ | |
40 | - * @package CoreExt_DataMapper | |
41 | - * @subpackage IntegrationTests | |
42 | - * @since Classe disponível desde a versão 1.1.0 | |
43 | - * @version @@package_version@@ | |
44 | - */ | |
45 | -class CoreExt_DataMapper_IntegrationCompoundPkeyTest extends IntegrationBaseTest | |
46 | -{ | |
47 | - /** | |
48 | - * Cria a tabela do objeto CoreExt_DataMapper para testes. | |
49 | - */ | |
50 | - public function __construct() | |
51 | - { | |
52 | - parent::__construct(); | |
53 | - CoreExt_EntityCompoundDataMapperStub::createTable($this->getDbAdapter()); | |
54 | - } | |
55 | - | |
56 | - protected function setUp() | |
57 | - { | |
58 | - parent::setUp(); | |
59 | - CoreExt_DataMapper::resetDefaultDbAdapter(); | |
60 | - } | |
61 | - | |
62 | - public function getDataSet() | |
63 | - { | |
64 | - return $this->createXMLDataSet($this->getFixture('matricula.xml')); | |
65 | - } | |
66 | - | |
67 | - public function testRecuperaRegistroUnico() | |
68 | - { | |
69 | - $mapper = new CoreExt_EntityCompoundDataMapperStub($this->getDbAdapter()); | |
70 | - $found = $mapper->find(array(1, 1)); | |
71 | - | |
72 | - $expected = new CoreExt_EntityCompoundStub(array( | |
73 | - 'pessoa' => 1, | |
74 | - 'curso' => 1, | |
75 | - 'confirmado' => TRUE | |
76 | - )); | |
77 | - | |
78 | - // Marca como se tivesse sido carregado, para garantir a comparação | |
79 | - $expected->markOld(); | |
80 | - | |
81 | - $this->assertEquals($expected, $found); | |
82 | - $this->assertFalse($found->isNew()); | |
83 | - } | |
84 | - | |
85 | - public function testCadastraNovoRegistroComChaveComposta() | |
86 | - { | |
87 | - $mapper = new CoreExt_EntityCompoundDataMapperStub($this->getDbAdapter()); | |
88 | - | |
89 | - $entity = new CoreExt_EntityCompoundStub(array( | |
90 | - 'pessoa' => 1, | |
91 | - 'curso' => 3, | |
92 | - 'confirmado' => TRUE | |
93 | - )); | |
94 | - | |
95 | - $mapper->save($entity); | |
96 | - | |
97 | - $this->assertTablesEqual( | |
98 | - $this->createXMLDataSet($this->getFixture('matricula-depois-salvo.xml')) | |
99 | - ->getTable('matricula'), | |
100 | - $this->getConnection() | |
101 | - ->createDataSet() | |
102 | - ->getTable('matricula') | |
103 | - ); | |
104 | - } | |
105 | - | |
106 | - public function testAtualizaRegistroComChaveComposta() | |
107 | - { | |
108 | - $mapper = new CoreExt_EntityCompoundDataMapperStub($this->getDbAdapter()); | |
109 | - | |
110 | - $entity = new CoreExt_EntityCompoundStub(array( | |
111 | - 'pessoa' => 1, | |
112 | - 'curso' => 2, | |
113 | - 'confirmado' => TRUE | |
114 | - )); | |
115 | - | |
116 | - // Marca como se tivesse sido carregado, para forçar CoreExt_DataMapper | |
117 | - // a usar o INSERT. | |
118 | - $entity->markOld(); | |
119 | - | |
120 | - $mapper->save($entity); | |
121 | - | |
122 | - $this->assertTablesEqual( | |
123 | - $this->createXMLDataSet($this->getFixture('matricula-depois-atualizado.xml')) | |
124 | - ->getTable('matricula'), | |
125 | - $this->getConnection() | |
126 | - ->createDataSet() | |
127 | - ->getTable('matricula') | |
128 | - ); | |
129 | - } | |
130 | - | |
131 | - public function testApagaRegistroComChaveComposta() | |
132 | - { | |
133 | - $mapper = new CoreExt_EntityCompoundDataMapperStub($this->getDbAdapter()); | |
134 | - | |
135 | - $entity = new CoreExt_EntityCompoundStub(array( | |
136 | - 'pessoa' => 1, | |
137 | - 'curso' => 2 | |
138 | - )); | |
139 | - | |
140 | - $mapper->delete($entity); | |
141 | - | |
142 | - $this->assertTablesEqual( | |
143 | - $this->createXMLDataSet($this->getFixture('matricula-depois-removido.xml')) | |
144 | - ->getTable('matricula'), | |
145 | - $this->getConnection() | |
146 | - ->createDataSet() | |
147 | - ->getTable('matricula') | |
148 | - ); | |
149 | - | |
150 | - // Apaga usando array com os valores da chave | |
151 | - $mapper->delete(array('pessoa' => 1, 'curso' => 1)); | |
152 | - $this->assertEquals(0, $this->getConnection()->createDataSet() | |
153 | - ->getTable('matricula')->getRowCount()); | |
154 | - } | |
155 | -} | |
156 | 0 | \ No newline at end of file |
ieducar/tests/unit/CoreExt/DataMapper/IntegrationTest.php
... | ... | @@ -1,247 +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 | - * @category i-Educar | |
25 | - * @license @@license@@ | |
26 | - * @package CoreExt_DataMapper | |
27 | - * @subpackage IntegrationTests | |
28 | - * @since Arquivo disponível desde a versão 1.1.0 | |
29 | - * @version $Id$ | |
30 | - */ | |
31 | - | |
32 | -require_once 'CoreExt/_stub/EntityDataMapper.php'; | |
33 | - | |
34 | -/** | |
35 | - * CoreExt_DataMapper_IntegrationTest class. | |
36 | - * | |
37 | - * @author Eriksen Costa Paixão <eriksen.paixao_bs@cobra.com.br> | |
38 | - * @category i-Educar | |
39 | - * @license @@license@@ | |
40 | - * @package CoreExt_DataMapper | |
41 | - * @subpackage IntegrationTests | |
42 | - * @since Classe disponível desde a versão 1.1.0 | |
43 | - * @version @@package_version@@ | |
44 | - */ | |
45 | -class CoreExt_DataMapper_IntegrationTest extends IntegrationBaseTest | |
46 | -{ | |
47 | - /** | |
48 | - * Cria a tabela do objeto CoreExt_DataMapper para testes. | |
49 | - */ | |
50 | - public function __construct() | |
51 | - { | |
52 | - parent::__construct(); | |
53 | - CoreExt_EntityDataMapperStub::createTable($this->getDbAdapter()); | |
54 | - } | |
55 | - | |
56 | - protected function setUp() | |
57 | - { | |
58 | - parent::setUp(); | |
59 | - CoreExt_DataMapper::resetDefaultDbAdapter(); | |
60 | - } | |
61 | - | |
62 | - public function getDataSet() | |
63 | - { | |
64 | - return $this->createXMLDataSet($this->getFixture('pessoa.xml')); | |
65 | - } | |
66 | - | |
67 | - public function testInicializaInstanciaDefaultDeClsbanco() | |
68 | - { | |
69 | - $mapper = new CoreExt_EntityDataMapperStub(); | |
70 | - $this->assertType('clsBanco', $mapper->getDbAdapter()); | |
71 | - } | |
72 | - | |
73 | - public function testRecuperaTodosOsRegistros() | |
74 | - { | |
75 | - $mapper = new CoreExt_EntityDataMapperStub($this->getDbAdapter()); | |
76 | - $found = $mapper->findAll(); | |
77 | - | |
78 | - $this->assertTablesEqual( | |
79 | - $this->getDataSet() | |
80 | - ->getTable('pessoa'), | |
81 | - $this->getConnection() | |
82 | - ->createDataSet() | |
83 | - ->getTable('pessoa') | |
84 | - ); | |
85 | - } | |
86 | - | |
87 | - public function testRecuperaTodosOsRegistrosSelecionandoColunasExplicitamente() | |
88 | - { | |
89 | - $expected = array( | |
90 | - new CoreExt_EntityStub(array('id' => 1, 'nome' => 'Arnaldo Antunes')), | |
91 | - new CoreExt_EntityStub(array('id' => 2, 'nome' => 'Marvin Gaye')) | |
92 | - ); | |
93 | - | |
94 | - // Marca como se tivesse sido carregado, para garantir a comparação | |
95 | - $expected[0]->markOld(); | |
96 | - $expected[1]->markOld(); | |
97 | - | |
98 | - $mapper = new CoreExt_EntityDataMapperStub($this->getDbAdapter()); | |
99 | - $found = $mapper->findAll(array('nome')); | |
100 | - | |
101 | - $this->assertEquals($expected, $found); | |
102 | - } | |
103 | - | |
104 | - public function testRecuperaRegistroUnico() | |
105 | - { | |
106 | - $mapper = new CoreExt_EntityDataMapperStub($this->getDbAdapter()); | |
107 | - $found = $mapper->find(1); | |
108 | - | |
109 | - $expected = new CoreExt_EntityStub(array( | |
110 | - 'id' => 1, | |
111 | - 'nome' => 'Arnaldo Antunes', | |
112 | - 'estadoCivil' => 'solteiro', | |
113 | - 'doador' => TRUE | |
114 | - )); | |
115 | - | |
116 | - // Marca como se tivesse sido carregado, para garantir a comparação | |
117 | - $expected->markOld(); | |
118 | - | |
119 | - $this->assertEquals($expected, $found); | |
120 | - $this->assertFalse($found->isNew()); | |
121 | - } | |
122 | - | |
123 | - public function testRecuperaRegistroComParametrosWhere() | |
124 | - { | |
125 | - $mapper = new CoreExt_EntityDataMapperStub($this->getDbAdapter()); | |
126 | - $found = $mapper->findAll(array(), array('estadoCivil' => 'solteiro')); | |
127 | - | |
128 | - $expected = new CoreExt_EntityStub(array( | |
129 | - 'id' => 1, | |
130 | - 'nome' => 'Arnaldo Antunes', | |
131 | - 'estadoCivil' => 'solteiro', | |
132 | - 'doador' => TRUE | |
133 | - )); | |
134 | - | |
135 | - // Marca como se tivesse sido carregado, para garantir a comparação | |
136 | - $expected->markOld(); | |
137 | - | |
138 | - $this->assertEquals($expected, $found[0]); | |
139 | - } | |
140 | - | |
141 | - public function testCadastraNovoRegistro() | |
142 | - { | |
143 | - $mapper = new CoreExt_EntityDataMapperStub($this->getDbAdapter()); | |
144 | - | |
145 | - $entity = new CoreExt_EntityStub(array( | |
146 | - 'nome' => 'Fernando Nascimento', | |
147 | - 'estadoCivil' => 'solteiro', | |
148 | - 'doador' => TRUE | |
149 | - )); | |
150 | - | |
151 | - $mapper->save($entity); | |
152 | - | |
153 | - $this->assertTablesEqual( | |
154 | - $this->createXMLDataSet($this->getFixture('pessoa-depois-salvo.xml')) | |
155 | - ->getTable('pessoa'), | |
156 | - $this->getConnection() | |
157 | - ->createDataSet() | |
158 | - ->getTable('pessoa') | |
159 | - ); | |
160 | - } | |
161 | - | |
162 | - public function testAtualizaRegistroCasoAChavePrimariaEstejaSetada() | |
163 | - { | |
164 | - $mapper = new CoreExt_EntityDataMapperStub($this->getDbAdapter()); | |
165 | - | |
166 | - $entity = new CoreExt_EntityStub(array( | |
167 | - 'id' => 2, | |
168 | - 'nome' => 'Marvin Gaye', | |
169 | - 'estadoCivil' => 'solteiro', | |
170 | - 'doador' => NULL | |
171 | - )); | |
172 | - | |
173 | - $mapper->save($entity); | |
174 | - | |
175 | - $this->assertTablesEqual( | |
176 | - $this->createXMLDataSet($this->getFixture('pessoa-depois-atualizado.xml')) | |
177 | - ->getTable('pessoa'), | |
178 | - $this->getConnection() | |
179 | - ->createDataSet() | |
180 | - ->getTable('pessoa') | |
181 | - ); | |
182 | - } | |
183 | - | |
184 | - /** | |
185 | - * @expectedException Exception | |
186 | - */ | |
187 | - public function testCadastraNovoRegistroLancaExcecaoNaoVerificadaNosErrosDeValidacao() | |
188 | - { | |
189 | - $mapper = new CoreExt_EntityDataMapperStub($this->getDbAdapter()); | |
190 | - | |
191 | - $entity = new CoreExt_EntityStub(array( | |
192 | - 'nome' => '', | |
193 | - 'estadoCivil' => 'solteiro', | |
194 | - 'doador' => TRUE | |
195 | - )); | |
196 | - | |
197 | - $mapper->save($entity); | |
198 | - } | |
199 | - | |
200 | - public function testAtualizaRegistro() | |
201 | - { | |
202 | - $mapper = new CoreExt_EntityDataMapperStub($this->getDbAdapter()); | |
203 | - $entity = $mapper->find(2); | |
204 | - $entity->estadoCivil = 'solteiro'; | |
205 | - $entity->doador = ''; | |
206 | - | |
207 | - $mapper->save($entity); | |
208 | - | |
209 | - $this->assertTablesEqual( | |
210 | - $this->createXMLDataSet($this->getFixture('pessoa-depois-atualizado.xml')) | |
211 | - ->getTable('pessoa'), | |
212 | - $this->getConnection() | |
213 | - ->createDataSet() | |
214 | - ->getTable('pessoa') | |
215 | - ); | |
216 | - } | |
217 | - | |
218 | - public function testApagaRegistroUsandoInstanciaDeEntity() | |
219 | - { | |
220 | - $mapper = new CoreExt_EntityDataMapperStub($this->getDbAdapter()); | |
221 | - $entity = $mapper->find(1); | |
222 | - | |
223 | - $mapper->delete($entity); | |
224 | - | |
225 | - $this->assertTablesEqual( | |
226 | - $this->createXMLDataSet($this->getFixture('pessoa-depois-removido.xml')) | |
227 | - ->getTable('pessoa'), | |
228 | - $this->getConnection() | |
229 | - ->createDataSet() | |
230 | - ->getTable('pessoa') | |
231 | - ); | |
232 | - } | |
233 | - | |
234 | - public function testApagaRegistroUsandoValorInteiro() | |
235 | - { | |
236 | - $mapper = new CoreExt_EntityDataMapperStub($this->getDbAdapter()); | |
237 | - $mapper->delete(1); | |
238 | - | |
239 | - $this->assertTablesEqual( | |
240 | - $this->createXMLDataSet($this->getFixture('pessoa-depois-removido.xml')) | |
241 | - ->getTable('pessoa'), | |
242 | - $this->getConnection() | |
243 | - ->createDataSet() | |
244 | - ->getTable('pessoa') | |
245 | - ); | |
246 | - } | |
247 | -} | |
248 | 0 | \ No newline at end of file |
ieducar/tests/unit/CoreExt/DataMapper/LazyLoadIntegrationTest.php
... | ... | @@ -1,190 +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 | - * @category i-Educar | |
25 | - * @license @@license@@ | |
26 | - * @package CoreExt_DataMapper | |
27 | - * @subpackage IntegrationTests | |
28 | - * @since Arquivo disponível desde a versão 1.1.0 | |
29 | - * @version $Id$ | |
30 | - */ | |
31 | - | |
32 | -require_once 'CoreExt/_stub/ParentEntityDataMapper.php'; | |
33 | -require_once 'CoreExt/_stub/ChildEntityDataMapper.php'; | |
34 | - | |
35 | -/** | |
36 | - * CoreExt_DataMapper_LazyLoadIntegrationTest class. | |
37 | - * | |
38 | - * @author Eriksen Costa Paixão <eriksen.paixao_bs@cobra.com.br> | |
39 | - * @category i-Educar | |
40 | - * @license @@license@@ | |
41 | - * @package CoreExt_DataMapper | |
42 | - * @subpackage IntegrationTests | |
43 | - * @since Classe disponível desde a versão 1.1.0 | |
44 | - * @version @@package_version@@ | |
45 | - */ | |
46 | -class CoreExt_DataMapper_LazyLoadIntegrationTest extends IntegrationBaseTest | |
47 | -{ | |
48 | - /** | |
49 | - * Cria as tabelas parent e child. | |
50 | - */ | |
51 | - public function __construct() | |
52 | - { | |
53 | - parent::__construct(); | |
54 | - CoreExt_DataMapper::setDefaultDbAdapter($this->getDbAdapter()); | |
55 | - CoreExt_ParentEntityDataMapperStub::createTable($this->getDbAdapter()); | |
56 | - CoreExt_ChildEntityDataMapperStub::createTable($this->getDbAdapter()); | |
57 | - } | |
58 | - | |
59 | - public function setUp() | |
60 | - { | |
61 | - parent::setUp(); | |
62 | - CoreExt_DataMapper::setDefaultDbAdapter($this->getDbAdapter()); | |
63 | - } | |
64 | - | |
65 | - public function getDataSet() | |
66 | - { | |
67 | - return $this->createXMLDataSet($this->getFixture('parent-child.xml')); | |
68 | - } | |
69 | - | |
70 | - public function testRecuperaTodosOsRegistros() | |
71 | - { | |
72 | - $mapper = new CoreExt_ParentEntityDataMapperStub(); | |
73 | - $found = $mapper->findAll(); | |
74 | - | |
75 | - $this->assertTablesEqual( | |
76 | - $this->getDataSet() | |
77 | - ->getTable('parent'), | |
78 | - $this->getConnection() | |
79 | - ->createDataSet() | |
80 | - ->getTable('parent') | |
81 | - ); | |
82 | - | |
83 | - $this->assertTablesEqual( | |
84 | - $this->getDataSet() | |
85 | - ->getTable('child'), | |
86 | - $this->getConnection() | |
87 | - ->createDataSet() | |
88 | - ->getTable('child') | |
89 | - ); | |
90 | - } | |
91 | - | |
92 | - public function testLazyLoadUsandoDefinicaoDeDataMapper() | |
93 | - { | |
94 | - $definition = array( | |
95 | - 'class' => 'CoreExt_ChildEntityDataMapperStub', | |
96 | - 'file' => 'CoreExt/_stub/ChildEntityDataMapper.php' | |
97 | - ); | |
98 | - | |
99 | - $parentMapper = new CoreExt_ParentEntityDataMapperStub(); | |
100 | - $parent = $parentMapper->find(1); | |
101 | - $parent->setReference('filho', $definition); | |
102 | - | |
103 | - $this->assertEquals(1, $parent->filho->id); | |
104 | - $this->assertEquals('Antunes Jr.', $parent->filho->nome); | |
105 | - } | |
106 | - | |
107 | - /** | |
108 | - * Uma referência NULL para CoreExt_Enum retorna NULL logo no início da | |
109 | - * lógica de CoreExt_Entity::_loadReference(). | |
110 | - * @group CoreExt_Entity | |
111 | - */ | |
112 | - public function testLazyLoadUsandoDefinicaoDeEnumComReferenciaNula() | |
113 | - { | |
114 | - $child = new CoreExt_ChildEntityStub( | |
115 | - array('id' => 3, 'sexo' => 1, 'tipoSanguineo' => NULL) | |
116 | - ); | |
117 | - $this->assertNull($child->tipoSanguineo); | |
118 | - } | |
119 | - | |
120 | - /** | |
121 | - * Referência 0 é perfeitamente válido para um CoreExt_Enum. Se não existir o | |
122 | - * offset no Enum, retorna NULL | |
123 | - * @group CoreExt_Entity | |
124 | - */ | |
125 | - public function testLazyLoadUsandoDefinicaoDeEnumComReferenciaZero() | |
126 | - { | |
127 | - $child = new CoreExt_ChildEntityStub( | |
128 | - array('id' => 3, 'sexo' => 1, 'tipoSanguineo' => 0) | |
129 | - ); | |
130 | - $this->assertNull($child->tipoSanguineo); | |
131 | - } | |
132 | - | |
133 | - /** | |
134 | - * Uma referência NULL é válida para as referências que explicitam a chave | |
135 | - * null = TRUE. | |
136 | - * @group CoreExt_Entity | |
137 | - */ | |
138 | - public function testLazyLoadUsandoDefinicaoDeDataMapperComReferenciaNula() | |
139 | - { | |
140 | - $parent = new CoreExt_ParentEntityStub( | |
141 | - array('id' => 3, 'nome' => 'Paul M.', 'filho' => NULL) | |
142 | - ); | |
143 | - $this->assertNull($parent->filho); | |
144 | - } | |
145 | - | |
146 | - /** | |
147 | - * Referência 0 em DataMapper força o retorno de NULL. Isso é feito em | |
148 | - * razão do HTML não suportar um valor NULL e por conta dos validadores | |
149 | - * client-side legados do i-Educar não considerarem "" (string vazia) um | |
150 | - * valor válido para submit. | |
151 | - * @group CoreExt_Entity | |
152 | - */ | |
153 | - public function testLazyLoadUsandoDefinicaoDeDataMapperComReferenciaZero() | |
154 | - { | |
155 | - $parent = new CoreExt_ParentEntityStub( | |
156 | - array('id' => 3, 'nome' => 'Paul M.', 'filho' => 0) | |
157 | - ); | |
158 | - $this->assertNull($parent->filho); | |
159 | - } | |
160 | - | |
161 | - public function testInsereRegistros() | |
162 | - { | |
163 | - $child = new CoreExt_ChildEntityStub(array('nome' => 'Nascimento Jr.')); | |
164 | - $childMapper = new CoreExt_ChildEntityDataMapperStub(); | |
165 | - $childMapper->save($child); | |
166 | - | |
167 | - $parent = new CoreExt_ParentEntityStub(array('nome' => 'Fernando Nascimento', 'filho' => 3)); | |
168 | - $parentMapper = new CoreExt_ParentEntityDataMapperStub(); | |
169 | - $parentMapper->save($parent); | |
170 | - | |
171 | - $parent = $parentMapper->find(3); | |
172 | - $child = $childMapper->find(3); | |
173 | - | |
174 | - $this->assertEquals($child, $parent->filho); | |
175 | - } | |
176 | - | |
177 | - /** | |
178 | - * Testa se um CoreExt_Entity retornado por um CoreExt_DataMapper configura | |
179 | - * a reference e o atributo, com um valor referência e a instância, | |
180 | - * respectivamente. | |
181 | - * @group Overload | |
182 | - */ | |
183 | - public function testRegistroRecuperadoConfiguraReferenceParaLazyLoadPosterior() | |
184 | - { | |
185 | - $parentMapper = new CoreExt_ParentEntityDataMapperStub(); | |
186 | - $parent = $parentMapper->find(1); | |
187 | - $this->assertEquals(1, $parent->get('filho')); | |
188 | - $this->assertType('CoreExt_ChildEntityStub', $parent->filho); | |
189 | - } | |
190 | -} | |
191 | 0 | \ No newline at end of file |
ieducar/tests/unit/CoreExt/DataMapper/StaticAdapterTest.php
... | ... | @@ -1,98 +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 | - * @category i-Educar | |
25 | - * @license @@license@@ | |
26 | - * @package CoreExt_DataMapper | |
27 | - * @subpackage IntegrationTests | |
28 | - * @since Arquivo disponível desde a versão 1.1.0 | |
29 | - * @version $Id$ | |
30 | - */ | |
31 | - | |
32 | -require_once 'CoreExt/_stub/EntityDataMapper.php'; | |
33 | - | |
34 | -/** | |
35 | - * CoreExt_DataMapper_StaticAdapterTest class. | |
36 | - * | |
37 | - * Classe com testes para assegurar que a interface de configuração de adapter | |
38 | - * de banco de dados estática de CoreExt_DataMapper funciona. | |
39 | - * | |
40 | - * @author Eriksen Costa Paixão <eriksen.paixao_bs@cobra.com.br> | |
41 | - * @category i-Educar | |
42 | - * @license @@license@@ | |
43 | - * @package CoreExt_DataMapper | |
44 | - * @subpackage IntegrationTests | |
45 | - * @since Classe disponível desde a versão 1.1.0 | |
46 | - * @version @@package_version@@ | |
47 | - */ | |
48 | -class CoreExt_DataMapper_StaticAdapterTest extends IntegrationBaseTest | |
49 | -{ | |
50 | - protected function setUp() | |
51 | - { | |
52 | - parent::setUp(); | |
53 | - CoreExt_DataMapper::setDefaultDbAdapter($this->getDbAdapter()); | |
54 | - } | |
55 | - | |
56 | - protected function tearDown() | |
57 | - { | |
58 | - parent::tearDown(); | |
59 | - CoreExt_DataMapper::resetDefaultDbAdapter(); | |
60 | - } | |
61 | - | |
62 | - public function getSetUpOperation() | |
63 | - { | |
64 | - return PHPUnit_Extensions_Database_Operation_Factory::NONE(); | |
65 | - } | |
66 | - | |
67 | - /** | |
68 | - * Esse método precisa ser sobrescrito mas a utilidade dele nesse teste é | |
69 | - * irrelevante. | |
70 | - */ | |
71 | - public function getDataSet() | |
72 | - { | |
73 | - return $this->createXMLDataSet($this->getFixture('pessoa.xml')); | |
74 | - } | |
75 | - | |
76 | - public function testAdapterParaNovaInstanciaDeDataMapperEOStatic() | |
77 | - { | |
78 | - $entityMapper = new CoreExt_EntityDataMapperStub(); | |
79 | - $this->assertSame($this->getDbAdapter(), $entityMapper->getDbAdapter()); | |
80 | - | |
81 | - $entityMapper = new CoreExt_EntityDataMapperStub(); | |
82 | - $this->assertSame($this->getDbAdapter(), $entityMapper->getDbAdapter()); | |
83 | - } | |
84 | - | |
85 | - public function testAdapterNoConstrutorSobrescreveOAdapterStaticPadrao() | |
86 | - { | |
87 | - $db = new CustomPdo('sqlite::memory:'); | |
88 | - $entityMapper = new CoreExt_EntityDataMapperStub($db); | |
89 | - $this->assertSame($db, $entityMapper->getDbAdapter()); | |
90 | - } | |
91 | - | |
92 | - public function testResetarAdapterFazComQueODataMapperInstancieUmNovoAdapter() | |
93 | - { | |
94 | - CoreExt_EntityDataMapperStub::resetDefaultDbAdapter(); | |
95 | - $entityMapper = new CoreExt_EntityDataMapperStub(); | |
96 | - $this->assertNotSame($this->getDbAdapter(), $entityMapper->getDbAdapter()); | |
97 | - } | |
98 | -} | |
99 | 0 | \ No newline at end of file |