define('GALETTE_VERSION', 'v0.9.3');
define('GALETTE_COMPAT_VERSION', '0.9.2');
-define('GALETTE_DB_VERSION', '0.930');
+define('GALETTE_DB_VERSION', '0.931');
if (!defined('GALETTE_MODE')) {
define('GALETTE_MODE', 'PROD'); //DEV, PROD, MAINT or DEMO
}
CREATE TABLE galette_database (
version DECIMAL(4,3) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-INSERT INTO galette_database(version) VALUES(0.93);
+INSERT INTO galette_database(version) VALUES(0.931);
SET FOREIGN_KEY_CHECKS=1;
MINVALUE 1
CACHE 1;
+-- sequence for texts
+DROP SEQUENCE IF EXISTS galette_texts_id_seq;
+CREATE SEQUENCE galette_texts_id_seq
+ START 1
+ INCREMENT 1
+ MAXVALUE 2147483647
+ MINVALUE 1
+ CACHE 1;
+
-- Schema
-- REMINDER: Create order IS important, dependencies first !!
DROP TABLE IF EXISTS galette_statuts CASCADE;
CREATE TABLE galette_database (
version decimal NOT NULL
);
-INSERT INTO galette_database (version) VALUES(0.93);
+INSERT INTO galette_database (version) VALUES(0.931);
--- /dev/null
+SET FOREIGN_KEY_CHECKS=0;
+
+UPDATE galette_database SET version = 0.931;
+SET FOREIGN_KEY_CHECKS=1;
--- /dev/null
+-- sequence for texts
+DROP SEQUENCE IF EXISTS galette_texts_id_seq;
+CREATE SEQUENCE galette_texts_id_seq
+ START 1
+ INCREMENT 1
+ MAXVALUE 2147483647
+ MINVALUE 1
+ CACHE 1;
+
+UPDATE galette_database SET version = 0.931;
*
* @category Core
* @package Galette
- *
* @author Johan Cwiklinski <johan@x-tnd.be>
* @copyright 2007-2014 The Galette Team
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL License 3.0 or (at your option) any later version
$delete = $zdb->delete(self::TABLE);
$zdb->execute($delete);
+ $zdb->handleSequence(
+ self::TABLE,
+ count($this->defaults)
+ );
+
$this->insert($zdb, $this->defaults);
Analog::log(
);
$knowns = array(
- '0.60' => 'upgrade-to-0.60-pgsql.sql',
- '0.61' => 'upgrade-to-0.61-pgsql.sql',
- '0.62' => 'upgrade-to-0.62-pgsql.sql',
- '0.63' => 'upgrade-to-0.63-pgsql.sql',
- '0.70' => 'upgrade-to-0.70.php',
- '0.71' => 'upgrade-to-0.71-pgsql.sql',
- '0.74' => 'upgrade-to-0.74-pgsql.sql',
- '0.75' => 'upgrade-to-0.75-pgsql.sql',
- '0.76' => 'upgrade-to-0.76-pgsql.sql',
- '0.8' => 'upgrade-to-0.8.php',
- '0.81' => 'upgrade-to-0.81-pgsql.sql',
- '0.82' => 'upgrade-to-0.82-pgsql.sql',
- '0.91' => 'upgrade-to-0.91-pgsql.sql',
- '0.92' => 'upgrade-to-0.92-pgsql.sql',
- '0.93' => 'upgrade-to-0.93-pgsql.sql'
+ '0.60' => 'upgrade-to-0.60-pgsql.sql',
+ '0.61' => 'upgrade-to-0.61-pgsql.sql',
+ '0.62' => 'upgrade-to-0.62-pgsql.sql',
+ '0.63' => 'upgrade-to-0.63-pgsql.sql',
+ '0.70' => 'upgrade-to-0.70.php',
+ '0.71' => 'upgrade-to-0.71-pgsql.sql',
+ '0.74' => 'upgrade-to-0.74-pgsql.sql',
+ '0.75' => 'upgrade-to-0.75-pgsql.sql',
+ '0.76' => 'upgrade-to-0.76-pgsql.sql',
+ '0.8' => 'upgrade-to-0.8.php',
+ '0.81' => 'upgrade-to-0.81-pgsql.sql',
+ '0.82' => 'upgrade-to-0.82-pgsql.sql',
+ '0.91' => 'upgrade-to-0.91-pgsql.sql',
+ '0.92' => 'upgrade-to-0.92-pgsql.sql',
+ '0.93' => 'upgrade-to-0.93-pgsql.sql',
+ '0.931' => 'upgrade-to-0.931-pgsql.sql'
);
$this->array($update_scripts)
--- /dev/null
+<?php
+
+/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
+
+/**
+ * Text tests
+ *
+ * PHP version 5
+ *
+ * Copyright © 2019 The Galette Team
+ *
+ * This file is part of Galette (http://galette.tuxfamily.org).
+ *
+ * Galette is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Galette 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Galette. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * @category Repository
+ * @package GaletteTests
+ *
+ * @author Johan Cwiklinski <johan@x-tnd.be>
+ * @copyright 2019 The Galette Team
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL License 3.0 or (at your option) any later version
+ * @version SVN: $Id$
+ * @link http://galette.tuxfamily.org
+ * @since 2019-12-20
+ */
+
+namespace Galette\Entity\test\units;
+
+use \atoum;
+use Zend\Db\Adapter\Adapter;
+
+/**
+ * Text tests
+ *
+ * @category Entity
+ * @name Texts
+ * @package GaletteTests
+ * @author Johan Cwiklinski <johan@x-tnd.be>
+ * @copyright 2020 The Galette Team
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL License 3.0 or (at your option) any later version
+ * @link http://galette.tuxfamily.org
+ * @since 2020-01-18
+ */
+class Texts extends atoum
+{
+ private $zdb;
+ private $remove = [];
+ private $i18n;
+ private $texts_fields;
+ private $preferences;
+
+ /**
+ * Set up tests
+ *
+ * @param string $testMethod Calling method
+ *
+ * @return void
+ */
+ public function beforeTestMethod($testMethod)
+ {
+ $this->zdb = new \Galette\Core\Db();
+ $this->i18n = new \Galette\Core\I18n(
+ \Galette\Core\I18n::DEFAULT_LANG
+ );
+ $this->preferences = new \Galette\Core\Preferences(
+ $this->zdb
+ );
+ include_once GALETTE_ROOT . 'includes/fields_defs/texts_fields.php';
+ $this->texts_fields = $texts_fields;
+ }
+
+ /**
+ * Test getList
+ *
+ * @return void
+ */
+ public function testGetList()
+ {
+ global $zdb;
+ $zdb = $this->zdb;
+
+ $texts = new \Galette\Entity\Texts(
+ $this->texts_fields,
+ $this->preferences
+ );
+ $texts->installInit();
+
+ $list = $texts->getRefs(\Galette\Core\I18n::DEFAULT_LANG);
+ $this->array($list)->hasSize(12);
+
+ if ($this->zdb->isPostgres()) {
+ $select = $this->zdb->select($texts::TABLE . '_id_seq');
+ $select->columns(['last_value']);
+ $results = $this->zdb->execute($select);
+ $result = $results->current();
+ $this->integer($result->last_value)
+ ->isGreaterThanOrEqualTo(12, 'Incorrect texts sequence ' . $result->last_value);
+
+ $this->zdb->db->query(
+ 'SELECT setval(\'' . PREFIX_DB . $texts::TABLE . '_id_seq\', 1)',
+ Adapter::QUERY_MODE_EXECUTE
+ );
+ }
+
+ //reinstall texts
+ $texts->installInit(false);
+
+ $list = $texts->getRefs('en_US');
+ $this->array($list)->hasSize(12);
+
+ if ($this->zdb->isPostgres()) {
+ $select = $this->zdb->select($texts::TABLE . '_id_seq');
+ $select->columns(['last_value']);
+ $results = $this->zdb->execute($select);
+ $result = $results->current();
+ $this->integer($result->last_value)
+ ->isGreaterThanOrEqualTo(12, 'Incorrect texts sequence ' . $result->last_value);
+ }
+ }
+}