]>
git.agnieray.net Git - galette.git/blob - tests/GaletteUpdate/Core/tests/units/Install.php
3 /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
10 * Copyright © 2021 The Galette Team
12 * This file is part of Galette (http://galette.tuxfamily.org).
14 * Galette is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation, either version 3 of the License, or
17 * (at your option) any later version.
19 * Galette is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with Galette. If not, see <http://www.gnu.org/licenses/>.
28 * @package GaletteTests
30 * @author Johan Cwiklinski <johan@x-tnd.be>
31 * @copyright 2021 The Galette Team
32 * @license http://www.gnu.org/licenses/gpl-3.0.html GPL License 3.0 or (at your option) any later version
34 * @link http://galette.tuxfamily.org
38 namespace Galette\Core\test\units
;
47 * @package GaletteTests
48 * @author Johan Cwiklinski <johan@x-tnd.be>
49 * @copyright 2021 The Galette Team
50 * @license http://www.gnu.org/licenses/gpl-3.0.html GPL License 3.0 or (at your option) any later version
51 * @link http://galette.tuxfamily.org
54 class Install
extends atoum
60 private $mocked_router;
66 * @param stgring $testMethod Method tested
70 public function beforeTestMethod($testMethod)
72 setlocale(LC_ALL
, 'en_US');
74 $this->mocked_router
= new \mock\Slim\
Router();
75 $this->calling($this->mocked_router
)->pathFor
= function ($name, $params) {
79 $this->flash_data
= &$flash_data;
80 $this->flash
= new \Slim\Flash\
Messages($flash_data);
82 $app = new \Galette\Core\
SlimApp();
83 $plugins = new \Galette\Core\
Plugins();
84 require GALETTE_BASE_PATH
. '/includes/dependencies.php';
85 $container = $app->getContainer();
86 $_SERVER['HTTP_HOST'] = '';
88 $container->set('flash', $this->flash
);
89 $container->set(Slim\Flash\Messages
::class, $this->flash
);
90 $container->set('router', $this->mocked_router
);
91 $container->set(Slim\Router
::class, $this->mocked_router
);
93 $this->container
= $container;
95 $this->zdb
= $container->get('zdb');
103 public function testUpdates()
105 $install = new \Galette\Core\
Install();
106 $update_scripts = \Galette\Core\Install
::getUpdateScripts(
107 GALETTE_BASE_PATH
. '/install',
111 $this->array($update_scripts)->size
->isGreaterThan(5);
113 $install->setMode(\Galette\Core\Install
::UPDATE
);
115 $install->setDbType($this->zdb
->type_db
, $errors);
116 $this->array($errors)->isIdenticalTo([]);
118 $install->setInstalledVersion('0.60');
119 $install->setTablesPrefix(PREFIX_DB
);
120 $exec = $install->executeScripts($this->zdb
, GALETTE_BASE_PATH
. '/install');
122 $report = $install->getInitializationReport();
123 foreach ($report as $entry) {
124 $this->boolean($entry['res'])->isTrue(($entry['debug'] ??
'') . "\n" . ($entry['query'] ??
''));
127 $this->boolean($exec)->isTrue();
128 $this->string($this->zdb
->getDbVersion())->isIdenticalTo(GALETTE_DB_VERSION
);