parent
746cc4b5d9
commit
7708b9901f
|
@ -46,11 +46,6 @@ namespace {
|
||||||
|
|
||||||
namespace Icinga\Test {
|
namespace Icinga\Test {
|
||||||
|
|
||||||
require_once 'Zend/Test/PHPUnit/ControllerTestCase.php';
|
|
||||||
require_once 'Zend/Db/Adapter/Pdo/Abstract.php';
|
|
||||||
require_once 'DbTest.php';
|
|
||||||
require_once 'FormTest.php';
|
|
||||||
// @codingStandardsIgnoreStart
|
|
||||||
use \Exception;
|
use \Exception;
|
||||||
use \RuntimeException;
|
use \RuntimeException;
|
||||||
use Zend_Test_PHPUnit_ControllerTestCase;
|
use Zend_Test_PHPUnit_ControllerTestCase;
|
||||||
|
@ -62,7 +57,6 @@ namespace Icinga\Test {
|
||||||
use Icinga\Data\ResourceFactory;
|
use Icinga\Data\ResourceFactory;
|
||||||
use Icinga\User\Preferences;
|
use Icinga\User\Preferences;
|
||||||
use Icinga\Web\Form;
|
use Icinga\Web\Form;
|
||||||
// @codingStandardsIgnoreEnd
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class BaseTestCase
|
* Class BaseTestCase
|
||||||
|
@ -206,8 +200,6 @@ namespace Icinga\Test {
|
||||||
*/
|
*/
|
||||||
private function createDbAdapterFor($name)
|
private function createDbAdapterFor($name)
|
||||||
{
|
{
|
||||||
$this->requireDbLibraries();
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$adapter = ResourceFactory::createResource($this->createDbConfigFor($name))->getConnection();
|
$adapter = ResourceFactory::createResource($this->createDbConfigFor($name))->getConnection();
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
|
@ -339,59 +331,7 @@ namespace Icinga\Test {
|
||||||
);
|
);
|
||||||
return $form;
|
return $form;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Require all libraries to instantiate forms
|
|
||||||
*/
|
|
||||||
public static function requireFormLibraries()
|
|
||||||
{
|
|
||||||
require_once 'Zend/Form/Decorator/Abstract.php';
|
|
||||||
require_once 'Zend/Validate/Abstract.php';
|
|
||||||
require_once 'Zend/Form/Element/Xhtml.php';
|
|
||||||
require_once 'Zend/Form/Element/Text.php';
|
|
||||||
require_once 'Zend/Form/Element/Submit.php';
|
|
||||||
require_once 'Zend/Form/Element/Checkbox.php';
|
|
||||||
require_once 'Zend/Form.php';
|
|
||||||
require_once 'Zend/View.php';
|
|
||||||
|
|
||||||
require_once self::$libDir . '/Web/Form/InvalidCSRFTokenException.php';
|
|
||||||
|
|
||||||
require_once self::$libDir . '/Web/Form/Element/DateTimePicker.php';
|
|
||||||
require_once self::$libDir . '/Web/Form/Element/Note.php';
|
|
||||||
require_once self::$libDir . '/Web/Form/Element/Number.php';
|
|
||||||
|
|
||||||
require_once self::$libDir . '/Web/Form/Decorator/ConditionalHidden.php';
|
|
||||||
require_once self::$libDir . '/Web/Form/Decorator/HelpText.php';
|
|
||||||
require_once self::$libDir . '/Web/Form/Decorator/BootstrapForm.php';
|
|
||||||
|
|
||||||
require_once self::$libDir . '/Web/Form/Validator/DateFormatValidator.php';
|
|
||||||
require_once self::$libDir . '/Web/Form/Validator/TimeFormatValidator.php';
|
|
||||||
require_once self::$libDir . '/Web/Form/Validator/WritablePathValidator.php';
|
|
||||||
|
|
||||||
require_once self::$libDir . '/Web/Form.php';
|
|
||||||
|
|
||||||
require_once self::$libDir . '/User/Preferences.php';
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Require all classes for database adapter creation
|
|
||||||
*/
|
|
||||||
public static function requireDbLibraries()
|
|
||||||
{
|
|
||||||
require_once 'Zend/Config.php';
|
|
||||||
require_once 'Zend/Db.php';
|
|
||||||
require_once 'Zend/Log.php';
|
|
||||||
|
|
||||||
require_once self::$libDir . '/Exception/ConfigurationError.php';
|
|
||||||
require_once self::$libDir . '/Util/ConfigAwareFactory.php';
|
|
||||||
require_once self::$libDir . '/Data/DatasourceInterface.php';
|
|
||||||
require_once self::$libDir . '/Data/ResourceFactory.php';
|
|
||||||
require_once self::$libDir . '/Data/Db/Connection.php';
|
|
||||||
require_once self::$libDir . '/Application/Logger.php';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BaseTestCase::setupDirectories();
|
BaseTestCase::setupDirectories();
|
||||||
BaseTestCase::requireFormLibraries();
|
|
||||||
BaseTestcase::requireDbLibraries();
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,7 +59,7 @@ class TestInit
|
||||||
|
|
||||||
require_once 'Zend/Loader/Autoloader.php';
|
require_once 'Zend/Loader/Autoloader.php';
|
||||||
\Zend_Loader_Autoloader::getInstance();
|
\Zend_Loader_Autoloader::getInstance();
|
||||||
|
|
||||||
Icinga\Application\Config::$configDir = $configPath;
|
Icinga\Application\Config::$configDir = $configPath;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,7 +74,6 @@ class AuthenticationFormTest extends BaseTestCase
|
||||||
*/
|
*/
|
||||||
public function testLdapProvider()
|
public function testLdapProvider()
|
||||||
{
|
{
|
||||||
$this->requireFormLibraries();
|
|
||||||
$form = $this->createForm('Icinga\Form\Config\Authentication\LdapBackendForm');
|
$form = $this->createForm('Icinga\Form\Config\Authentication\LdapBackendForm');
|
||||||
$config = new Zend_Config(
|
$config = new Zend_Config(
|
||||||
array(
|
array(
|
||||||
|
@ -107,7 +106,6 @@ class AuthenticationFormTest extends BaseTestCase
|
||||||
*/
|
*/
|
||||||
public function testDbProvider()
|
public function testDbProvider()
|
||||||
{
|
{
|
||||||
$this->requireFormLibraries();
|
|
||||||
$form = $this->createForm('Icinga\Form\Config\Authentication\DbBackendForm');
|
$form = $this->createForm('Icinga\Form\Config\Authentication\DbBackendForm');
|
||||||
$config = new Zend_Config(
|
$config = new Zend_Config(
|
||||||
array(
|
array(
|
||||||
|
@ -150,7 +148,6 @@ class AuthenticationFormTest extends BaseTestCase
|
||||||
public function testModifyOrder()
|
public function testModifyOrder()
|
||||||
{
|
{
|
||||||
Url::$overwrittenRequest = new RequestMock();
|
Url::$overwrittenRequest = new RequestMock();
|
||||||
$this->requireFormLibraries();
|
|
||||||
$form = $this->createForm('Icinga\Form\Config\Authentication\ReorderForm');
|
$form = $this->createForm('Icinga\Form\Config\Authentication\ReorderForm');
|
||||||
$form->setAuthenticationBackend('backend2');
|
$form->setAuthenticationBackend('backend2');
|
||||||
$form->setCurrentOrder(array('backend1', 'backend2', 'backend3', 'backend4'));
|
$form->setCurrentOrder(array('backend1', 'backend2', 'backend3', 'backend4'));
|
||||||
|
@ -191,7 +188,6 @@ class AuthenticationFormTest extends BaseTestCase
|
||||||
public function testInvalidOrderingNotShown()
|
public function testInvalidOrderingNotShown()
|
||||||
{
|
{
|
||||||
Url::$overwrittenRequest = new RequestMock();
|
Url::$overwrittenRequest = new RequestMock();
|
||||||
$this->requireFormLibraries();
|
|
||||||
$form = $this->createForm('Icinga\Form\Config\Authentication\ReorderForm');
|
$form = $this->createForm('Icinga\Form\Config\Authentication\ReorderForm');
|
||||||
$form->setAuthenticationBackend('backend1');
|
$form->setAuthenticationBackend('backend1');
|
||||||
$form->setCurrentOrder(array('backend1', 'backend2', 'backend3', 'backend4'));
|
$form->setCurrentOrder(array('backend1', 'backend2', 'backend3', 'backend4'));
|
||||||
|
|
|
@ -63,7 +63,6 @@ class GeneralFormTest extends BaseTestCase
|
||||||
public function testCorrectFieldPopulation()
|
public function testCorrectFieldPopulation()
|
||||||
{
|
{
|
||||||
DateTimeFactory::setConfig(array('timezone' => new DateTimeZone('UTC')));
|
DateTimeFactory::setConfig(array('timezone' => new DateTimeZone('UTC')));
|
||||||
$this->requireFormLibraries();
|
|
||||||
$form = $this->createForm('Icinga\Form\Config\GeneralForm');
|
$form = $this->createForm('Icinga\Form\Config\GeneralForm');
|
||||||
$form->setDateFormatter(new Zend_View_Helper_DateFormat($this->getRequest()));
|
$form->setDateFormatter(new Zend_View_Helper_DateFormat($this->getRequest()));
|
||||||
$form->setConfiguration(
|
$form->setConfiguration(
|
||||||
|
@ -140,7 +139,6 @@ class GeneralFormTest extends BaseTestCase
|
||||||
public function testCorrectConditionalIniFieldRendering()
|
public function testCorrectConditionalIniFieldRendering()
|
||||||
{
|
{
|
||||||
DateTimeFactory::setConfig(array('timezone' => new DateTimeZone('UTC')));
|
DateTimeFactory::setConfig(array('timezone' => new DateTimeZone('UTC')));
|
||||||
$this->requireFormLibraries();
|
|
||||||
$form = $this->createForm('Icinga\Form\Config\GeneralForm');
|
$form = $this->createForm('Icinga\Form\Config\GeneralForm');
|
||||||
$form->setDateFormatter(new Zend_View_Helper_DateFormat($this->getRequest()));
|
$form->setDateFormatter(new Zend_View_Helper_DateFormat($this->getRequest()));
|
||||||
$form->setConfiguration(
|
$form->setConfiguration(
|
||||||
|
@ -178,7 +176,6 @@ class GeneralFormTest extends BaseTestCase
|
||||||
public function testCorrectConditionalDbFieldRendering()
|
public function testCorrectConditionalDbFieldRendering()
|
||||||
{
|
{
|
||||||
DateTimeFactory::setConfig(array('timezone' => new DateTimeZone('UTC')));
|
DateTimeFactory::setConfig(array('timezone' => new DateTimeZone('UTC')));
|
||||||
$this->requireFormLibraries();
|
|
||||||
$form = $this->createForm('Icinga\Form\Config\GeneralForm');
|
$form = $this->createForm('Icinga\Form\Config\GeneralForm');
|
||||||
$form->setDateFormatter(new Zend_View_Helper_DateFormat($this->getRequest()));
|
$form->setDateFormatter(new Zend_View_Helper_DateFormat($this->getRequest()));
|
||||||
$form->setConfiguration(
|
$form->setConfiguration(
|
||||||
|
|
|
@ -44,7 +44,6 @@ class LoggingFormTest extends BaseTestCase
|
||||||
*/
|
*/
|
||||||
public function testLoggingFormPopulation()
|
public function testLoggingFormPopulation()
|
||||||
{
|
{
|
||||||
$this->requireFormLibraries();
|
|
||||||
$form = $this->createForm('Icinga\Form\Config\LoggingForm');
|
$form = $this->createForm('Icinga\Form\Config\LoggingForm');
|
||||||
$config = new Zend_Config(
|
$config = new Zend_Config(
|
||||||
array(
|
array(
|
||||||
|
@ -93,7 +92,6 @@ class LoggingFormTest extends BaseTestCase
|
||||||
*/
|
*/
|
||||||
public function testCorrectConfigCreation()
|
public function testCorrectConfigCreation()
|
||||||
{
|
{
|
||||||
$this->requireFormLibraries();
|
|
||||||
$form = $this->createForm(
|
$form = $this->createForm(
|
||||||
'Icinga\Form\Config\LoggingForm',
|
'Icinga\Form\Config\LoggingForm',
|
||||||
array(
|
array(
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*#
|
||||||
* @copyright 2013 Icinga Development Team <info@icinga.org>
|
* @copyright 2013 Icinga Development Team <info@icinga.org>
|
||||||
* @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2
|
* @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2
|
||||||
* @author Icinga Development Team <info@icinga.org>
|
* @author Icinga Development Team <info@icinga.org>
|
||||||
|
@ -29,23 +29,8 @@
|
||||||
|
|
||||||
namespace Icinga\Test\Form\Preference;
|
namespace Icinga\Test\Form\Preference;
|
||||||
|
|
||||||
// @codingStandardsIgnoreStart
|
|
||||||
require_once realpath(__DIR__ . '/../../../../../library/Icinga/Test/BaseTestCase.php');
|
|
||||||
// @codingStandardsIgnoreEnd
|
|
||||||
|
|
||||||
use Icinga\Test\BaseTestCase;
|
use Icinga\Test\BaseTestCase;
|
||||||
|
|
||||||
// @codingStandardsIgnoreStart
|
|
||||||
require_once 'Zend/Form/Element/Select.php';
|
|
||||||
require_once 'Zend/View/Helper/Abstract.php';
|
|
||||||
require_once BaseTestCase::$libDir . '/User/Preferences.php';
|
|
||||||
require_once BaseTestCase::$libDir . '/Web/Form.php';
|
|
||||||
require_once BaseTestCase::$appDir . '/forms/Preference/GeneralForm.php';
|
|
||||||
require_once BaseTestCase::$appDir . '/views/helpers/DateFormat.php';
|
|
||||||
require_once BaseTestCase::$libDir . '/Util/ConfigAwareFactory.php';
|
|
||||||
require_once BaseTestCase::$libDir . '/Util/DateTimeFactory.php';
|
|
||||||
// @codingStandardsIgnoreEnd
|
|
||||||
|
|
||||||
use \DateTimeZone;
|
use \DateTimeZone;
|
||||||
use \Icinga\User\Preferences;
|
use \Icinga\User\Preferences;
|
||||||
use \Zend_View_Helper_DateFormat;
|
use \Zend_View_Helper_DateFormat;
|
||||||
|
@ -63,7 +48,6 @@ class GeneralFormTest extends BaseTestCase
|
||||||
public function testDisableFormIfUsingDefault()
|
public function testDisableFormIfUsingDefault()
|
||||||
{
|
{
|
||||||
DateTimeFactory::setConfig(array('timezone' => new DateTimeZone('UTC')));
|
DateTimeFactory::setConfig(array('timezone' => new DateTimeZone('UTC')));
|
||||||
$this->requireFormLibraries();
|
|
||||||
$form = $this->createForm('Icinga\Form\Preference\GeneralForm');
|
$form = $this->createForm('Icinga\Form\Preference\GeneralForm');
|
||||||
$form->setDateFormatter(new Zend_View_Helper_DateFormat($this->getRequest()));
|
$form->setDateFormatter(new Zend_View_Helper_DateFormat($this->getRequest()));
|
||||||
$form->setRequest($this->getRequest());
|
$form->setRequest($this->getRequest());
|
||||||
|
@ -82,7 +66,6 @@ class GeneralFormTest extends BaseTestCase
|
||||||
public function testEnableFormIfUsingPreference()
|
public function testEnableFormIfUsingPreference()
|
||||||
{
|
{
|
||||||
DateTimeFactory::setConfig(array('timezone' => new DateTimeZone('UTC')));
|
DateTimeFactory::setConfig(array('timezone' => new DateTimeZone('UTC')));
|
||||||
$this->requireFormLibraries();
|
|
||||||
$form = $this->createForm('Icinga\Form\Preference\GeneralForm');
|
$form = $this->createForm('Icinga\Form\Preference\GeneralForm');
|
||||||
$form->setDateFormatter(new Zend_View_Helper_DateFormat($this->getRequest()));
|
$form->setDateFormatter(new Zend_View_Helper_DateFormat($this->getRequest()));
|
||||||
$form->setRequest($this->getRequest());
|
$form->setRequest($this->getRequest());
|
||||||
|
|
Loading…
Reference in New Issue