/**
  * Runs after each test.
  *
  * @return void
  */
 public function tearDown()
 {
     parent::tearDown();
     Setting::clear(true);
     Configure::write('CA.PostTypes', []);
     Configure::write('CA.Models', []);
 }
 /**
  * index action
  *
  * Shows all settings with the specific prefix.
  *
  * @param string $key The prefix.
  * @return void|\Cake\Network\Respose
  * @throws NotFoundException
  */
 public function index($key = null)
 {
     if (!$key) {
         $key = 'App';
     }
     $this->Menu->active($this->prefixes[$key]);
     if (!$this->__prefixExists($key)) {
         throw new NotFoundException("The prefix-setting " . $key . " could not be found");
     }
     $prefix = Hash::get($this->prefixes, ucfirst($key));
     $settings = $this->Configurations->find('all')->where(['name LIKE' => $key . '%', 'editable' => 1])->order(['weight', 'id']);
     if ($this->request->is(['patch', 'post', 'put'])) {
         $settings = $this->Configurations->patchEntities($settings, $this->request->data);
         foreach ($settings as $setting) {
             $this->Flash->success('The settings has been saved.');
             if (!$this->Configurations->save($setting)) {
                 $this->Flash->error('The settings could not be saved. Please, try again.');
             }
         }
         Setting::clear(true);
         Setting::autoLoad();
         return $this->redirect([]);
     }
     $this->set(compact('prefix', 'settings'));
 }
Пример #3
0
 /**
  * Test autoload-method
  *
  * @return void
  */
 public function testAutoload()
 {
     Setting::write('App.Test1', 'Test1');
     Setting::write('App.Test2', 'Test2');
     Setting::clear();
     $this->assertEmpty(Setting::read());
     Setting::clear(true);
     Setting::autoLoad();
     $_array = ['App.Test1' => 'Test1', 'App.Test2' => 'Test2'];
     $this->assertEquals($_array, Setting::read());
 }