File indexing completed on 2025-02-09 07:20:59

0001 <?php
0002 /**
0003  *  ocs-webserver
0004  *
0005  *  Copyright 2016 by pling GmbH.
0006  *
0007  *    This file is part of ocs-webserver.
0008  *
0009  *    This program is free software: you can redistribute it and/or modify
0010  *    it under the terms of the GNU Affero General Public License as
0011  *    published by the Free Software Foundation, either version 3 of the
0012  *    License, or (at your option) any later version.
0013  *
0014  *    This program is distributed in the hope that it will be useful,
0015  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
0016  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0017  *    GNU Affero General Public License for more details.
0018  *
0019  *    You should have received a copy of the GNU Affero General Public License
0020  *    along with this program.  If not, see <http://www.gnu.org/licenses/>.
0021  **/
0022 
0023 // Sorry autoloader doesn't work for me
0024 require_once(APPLICATION_PATH . '/modules/backend/models/ClientFileConfig.php');
0025 
0026 class Backend_Model_ClientFileConfigTest extends PHPUnit_Framework_TestCase
0027 {
0028 
0029     protected function setUp()
0030     {
0031         require_once APPLICATION_LIB . '/Local/Application.php';
0032 
0033         // Create application, bootstrap, and run
0034         $this->bootstrap = new Local_Application(
0035             APPLICATION_ENV,
0036             Zend_Registry::get('configuration'),
0037             Zend_Registry::get('cache')
0038         );
0039 
0040         $this->bootstrap->bootstrap('autoload');
0041 
0042         parent::setUp(); // TODO: Change the autogenerated stub
0043 
0044         /** @var Zend_Config $config */
0045         $config = new Zend_Config($this->bootstrap->getOptions(), true);
0046         $config->settings->client->config->path = TEST_PATH . '/_files/configs/';
0047         Zend_Registry::set('config', $config);
0048     }
0049 
0050     protected function tearDown()
0051     {
0052         parent::tearDown(); // TODO: Change the autogenerated stub
0053     }
0054 
0055     public function testInitConfigReader()
0056     {
0057         $clientConfigReader = new Backend_Model_ClientFileConfig(null);
0058         $this->assertNull($clientConfigReader->getConfig());
0059     }
0060 
0061     public function testSetClientName()
0062     {
0063         $clientConfigReader = new Backend_Model_ClientFileConfig('test');
0064         $this->assertEquals('test', $clientConfigReader->getClientName());
0065     }
0066 
0067     public function testLoadClientConfig()
0068     {
0069         $clientConfigReader = new Backend_Model_ClientFileConfig(null);
0070         $clientConfigReader->loadClientConfig('test');
0071         $this->assertEquals('pling.it', $clientConfigReader->getConfig()['head']['browser_title']);
0072     }
0073 
0074     public function testGetForm()
0075     {
0076         $clientConfigReader = new Backend_Model_ClientFileConfig(null);
0077         $clientConfigReader->loadClientConfig('test');
0078         $form = $clientConfigReader->getForm();
0079         $this->assertInstanceOf('Zend_Form', $form);
0080     }
0081 
0082 }