diff --git a/library/Class/Migration/CleanCustomfieldsFacets.php b/library/Class/Migration/CleanCustomFieldsFacets.php similarity index 100% rename from library/Class/Migration/CleanCustomfieldsFacets.php rename to library/Class/Migration/CleanCustomFieldsFacets.php diff --git a/tests/library/Class/Migration/CleanCustomFieldsFacetsTest.php b/tests/library/Class/Migration/CleanCustomFieldsFacetsTest.php new file mode 100644 index 0000000000000000000000000000000000000000..17548076be623fd11ff69a34ce5dc02c5fd77903 --- /dev/null +++ b/tests/library/Class/Migration/CleanCustomFieldsFacetsTest.php @@ -0,0 +1,72 @@ +<?php +/** + * Copyright (c) 2012-2016, Agence Française Informatique (AFI). All rights reserved. + * + * BOKEH is free software; you can redistribute it and/or modify + * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by + * the Free Software Foundation. + * + * There are special exceptions to the terms and conditions of the AGPL as it + * is applied to this software (see README file). + * + * BOKEH is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE + * along with BOKEH; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + + +class Class_Migration_CleanCustomFieldsFacetsTest extends ModelTestCase { + protected $_storm_default_to_volatile = true, + $_response = false; + + + public function setUp() { + parent::setUp(); + + $this->_response = false; + + $thesaurus = $this->fixture('Class_CodifThesaurus', + ['id' => 3, + 'id_origine' => 45, + 'code' => 'Custom fields', + 'libelle' => 'Custom public', + 'id_thesaurus' => 'CFCF0001']); + + $sql = $this->mock() + ->whenCalled('execute') + ->with('delete from codif_thesaurus where id_thesaurus like "CFCF0001%"') + ->willDo(function() + { + Class_CodifThesaurus::find(3)->delete(); + }); + + Zend_Registry::set('sql', $sql); + + $this->onLoaderOfModel('Class_CodifThesaurus') + ->whenCalled('findChildrenOf') + ->answers([$thesaurus]); + } + + + /** @test */ + public function customPublicShouldHaveBeenDeleted() { + (new Class_Migration_CleanCustomFieldsFacets())->run(); + $this->assertNull(Class_CodifThesaurus::find(3)); + } + + + /** @test */ + public function customPublicShouldNotHaveBeenDeleted() { + $this->fixture('Class_CustomField_Meta', + ['id' => 45, + 'indexable' => 1]); + + (new Class_Migration_CleanCustomFieldsFacets())->run(); + $this->assertNotNull(Class_CodifThesaurus::find(3)); + } +} \ No newline at end of file