Skip to content
Snippets Groups Projects
Commit 61d2ca1d authored by Bertrand Gauthier's avatar Bertrand Gauthier
Browse files

Suppression de ce qui concerne MySQL car ce n'est pas exploitable.

parent 87c7ffd2
No related branches found
No related tags found
No related merge requests found
Showing
with 0 additions and 156 deletions
<?php
namespace UnicaenDbImportUnitTest\CodeGenerator\MySQL;
use UnicaenDbImport\CodeGenerator\MySQL\MySQLCodeGenerator;
use UnicaenDbImport\CodeGenerator\MySQL\MySQLCodeGeneratorFactory;
use Zend\ServiceManager\ServiceLocatorInterface;
class MySQLCodeGeneratorFactoryTest extends \PHPUnit_Framework_TestCase
{
public function test_can_create_service()
{
/** @var ServiceLocatorInterface|\PHPUnit_Framework_MockObject_MockObject $sl */
$sl = $this->createMock(ServiceLocatorInterface::class);
$sl->expects($this->never())->method('get');
$factory = new MySQLCodeGeneratorFactory();
$service = $factory->__invoke($sl);
$this->assertInstanceOf(MySQLCodeGenerator::class, $service);
}
}
\ No newline at end of file
<?php
namespace UnicaenDbImportUnitTest\CodeGenerator\MySQL;
use UnicaenDbImport\CodeGenerator\MySQL\MySQLCodeGenerator;
use UnicaenDbImport\Domain\SourceInterface;
use UnicaenDbImportUnitTest\CodeGenerator\CodeGeneratorAbstractTest;
class MySQLCodeGeneratorTest extends CodeGeneratorAbstractTest
{
protected function setUp()
{
parent::setUp();
$this->codeGenerator = new MySQLCodeGenerator();
$this->dir = __DIR__;
}
/**
* @return SourceInterface|\PHPUnit_Framework_MockObject_MockObject
*/
protected function createSourceMockFor_test_can_generate_sql_for_full_outer_join_select()
{
$source = parent::createSourceMockFor_test_can_generate_sql_for_full_outer_join_select();
$source->expects($this->once())->method('getColumns')->willReturn(['libelle', 'debut_validite', 'fin_validite']);
return $source;
}
}
\ No newline at end of file
insert into src_ztemptable (code, libelle, debut_validite, fin_validite) values ('A006', 'Libellé d''aujourd''hui (NB: l''apostrophe)', '2017-03-11', '2018-03-11');
\ No newline at end of file
drop table if exists src_ztemptable CASCADE;
create table src_ztemptable as select code, libelle, debut_validite, fin_validite from ztemptable;
delete from src_ztemptable;
\ No newline at end of file
select code, libelle, debut_validite, fin_validite from ztemptable;
\ No newline at end of file
DELIMITER $$
drop function get_import_req_ztemptable; $$
CREATE FUNCTION get_import_req_ztemptable(
operation TEXT,
sourceCodeColumnValue TEXT,
src_libelle TEXT, src_debut_validite TEXT, src_fin_validite TEXT,
dest_libelle TEXT, dest_debut_validite TEXT, dest_fin_validite TEXT
) RETURNS TEXT
DETERMINISTIC
BEGIN
CASE operation
WHEN 'insert' THEN
RETURN concat(
'insert into ztemptable(created_on, code, libelle, debut_validite, fin_validite) ',
'select now(), ', sourceCodeColumnValue,
QUOTE(dest_libelle), QUOTE(dest_debut_validite), QUOTE(dest_fin_validite),
' ;');
WHEN 'update' THEN
IF (src_libelle <> dest_libelle OR src_debut_validite <> dest_debut_validite OR src_fin_validite <> dest_fin_validite) THEN
RETURN concat(
'update ztemptable set updated_on = now(), ',
'libelle = ', QUOTE(dest_libelle), 'debut_validite = ', QUOTE(dest_debut_validite), 'fin_validite = ', QUOTE(dest_fin_validite),
'where code = ', sourceCodeColumnValue,
' ;');
END IF;
WHEN 'undelete' THEN
RETURN concat(
'update ztemptable set updated_on = now(), deleted_on = NULL, ',
'libelle = ', QUOTE(dest_libelle), 'debut_validite = ', QUOTE(dest_debut_validite), 'fin_validite = ', QUOTE(dest_fin_validite),
'where code = ', sourceCodeColumnValue,
' ;');
WHEN 'delete' THEN
RETURN concat(
'update ztemptable set deleted_on = now() ',
'where code = ', sourceCodeColumnValue,
' ;');
ELSE
RETURN NULL;
END CASE;
RETURN NULL;
END; $$
DELIMITER ;
SELECT
get_import_operation(src.code, dest.code, dest.deleted_on) operation,
get_import_req_ztemptable(
get_import_operation(src.code, dest.code, dest.deleted_on),
src.code,
src.libelle, src.debut_validite, src.fin_validite
) req
FROM src_ztemptable src
FULL OUTER JOIN ztemptable dest ON src.code = dest.code
WHERE
get_import_req_ztemptable(
get_import_operation(src.code, dest.code, dest.deleted_on),
src.code,
src.libelle, src.debut_validite, src.fin_validite
) is not null
;
\ No newline at end of file
<?php
namespace UnicaenDbImportUnitTest\Importer\MySQL;
use UnicaenDbImport\Importer\MySQL\MySQLImporter;
use UnicaenDbImport\Importer\MySQL\MySQLImporterFactory;
use Zend\ServiceManager\ServiceLocatorInterface;
class MySQLImporterFactoryTest extends \PHPUnit_Framework_TestCase
{
public function test_can_create_service()
{
/** @var ServiceLocatorInterface|\PHPUnit_Framework_MockObject_MockObject $sl */
$sl = $this->createMock(ServiceLocatorInterface::class);
$sl->expects($this->never())->method('get');
$factory = new MySQLImporterFactory();
$service = $factory->__invoke($sl);
$this->assertInstanceOf(MySQLImporter::class, $service);
}
}
\ No newline at end of file
<?php
namespace UnicaenDbImportUnitTest\Importer\MySQL;
use UnicaenDbImport\Importer\MySQL\MySQLImporter;
use UnicaenDbImportUnitTest\Importer\ImporterAbstractTest;
class MySQLImporterTest extends ImporterAbstractTest
{
protected function setUp()
{
parent::setUp();
$this->importer = new MySQLImporter($this->databaseHelper);
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment