/** * Test preferences initialization * * @return void */ public function testInstallInit() { $result = $this->_preferences->installInit('en_US', 'da_admin', password_hash('da_secret', PASSWORD_BCRYPT)); $this->boolean($result)->isTrue(); //new object with values loaded from database to compare $prefs = new \Galette\Core\Preferences($this->_zdb); foreach ($prefs->getDefaults() as $key => $expected) { $value = $prefs->{$key}; switch ($key) { case 'pref_admin_login': $this->variable($value)->isIdenticalTo('da_admin'); break; case 'pref_admin_pass': $pw_checked = password_verify('da_secret', $value); $this->boolean($pw_checked)->isTrue(); break; case 'pref_lang': $this->variable($value)->isIdenticalTo('en_US'); break; case 'pref_card_year': $this->variable($value)->isIdenticalTo(date('Y')); break; default: if (TYPE_DB === \Galette\Core\Db::PGSQL) { if ($value === 'f') { $value = false; } } $this->variable($value)->isEqualTo($expected); break; } } //tru to set and get a non existent value $prefs->doesnotexists = 'that *does* not exists.'; $false_result = $prefs->doesnotexists; $this->boolean($false_result)->isFalse(); //change slogan $slogan = 'One Galette to rule them all'; $prefs->pref_slogan = $slogan; $check = $prefs->pref_slogan; $this->string($check)->isIdenticalTo($slogan); //change password $new_pass = '******'; $prefs->pref_admin_pass = $new_pass; $pass = $prefs->pref_admin_pass; $pw_checked = password_verify($new_pass, $pass); $this->boolean($pw_checked)->isTrue(); $this->_preferences->pref_nom = 'Galette'; $this->_preferences->pref_ville = 'Avignon'; $this->_preferences->pref_cp = '84000'; $this->_preferences->pref_adresse = 'Palais des Papes'; $this->_preferences->pref_adresse2 = 'Au milieu'; $this->_preferences->pref_pays = 'France'; $expected = "Galette\n\nPalais des Papes\nAu milieu\n84000 Avignon - France"; $address = $this->_preferences->getPostalAddress(); $this->variable($address)->isIdenticalTo($expected); $slogan = $this->_preferences->pref_slogan; $this->variable($slogan)->isEqualTo(''); $slogan = 'One Galette to rule them all'; $this->_preferences->pref_slogan = $slogan; $result = $this->_preferences->store(); $this->boolean($result)->isTrue(); $prefs = new \Galette\Core\Preferences($this->_zdb); $check_slogan = $prefs->pref_slogan; $this->variable($check_slogan)->isEqualTo($slogan); //reset database value... $this->_preferences->pref_slogan = ''; $this->_preferences->store(); }
$errs[] = '<li class="install-bad">' . _T("Default fields configuration cannot be initialized.") . '</li>'; } else { $oks[] = '<li class="install-ok">' . _T("Default fields configuration was successfully stored.") . '</li>'; } if ((double) $_to_ver >= 0.7) { //once fields configuration defaults has been stored, we'll //report galette_required values, and we remove that table $res = $fc->migrateRequired($zdb); if ($res !== true) { $errs[] = '<li class="install-bad">' . _T("Required fields upgrade has failed :(") . '<span>' . $res->getMessage() . '</span></li>'; } else { $oks[] = '<li class="install-ok">' . _T("Required fields have been upgraded successfully.") . '</li>'; } } } $preferences = new Galette\Core\Preferences($zdb); $preferences->pref_admin_login = $_POST['install_adminlogin']; $preferences->pref_admin_pass = $_POST['install_adminpass']; $preferences->store(); } } include_once GALETTE_ROOT . 'includes/fields_defs/texts_fields.php'; $texts = new Galette\Entity\Texts($texts_fields, $preferences); $res = $texts->installInit(); if ($res !== false) { if ($res !== true) { $errs[] = '<li class="install-bad">' . _T("Default texts cannot be initialized.") . '<span>' . $res->getMessage() . '</span></li>'; } else { $oks[] = '<li class="install-ok">' . _T("Default texts were successfully stored.") . '</li>'; } }