Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/site/app/tests/controllers/api_controller.test.php
blob: e3a6ef2347611b75333bbd4876d06afb75e15911 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?php

class ApiControllerTest extends WebTestHelper {

    function setUp() {

        $this->helper = new UnitTestHelper();
        $this->controller = $this->helper->getController('Api', $this);
        loadModel('Config');
        $this->Config =& new Config();
        $this->Config->caching = False;
        $this->Config->cacheQueries = False;

        // Store the old value so we can reset it in teardown.
        $this->_oldVal = $this->Config->getValue('api_disabled');
        // Make sure the api is disabled.
        $this->Config->save(array('key' => 'api_disabled',
                                  'value' => '1'));
        // Clear out the config cache.
        $this->Config->expire();
    }

    function tearDown() {
        $this->Config->save(array('key' => 'api_disabled',
                                  'value' => $this->_oldVal));
    }

    function testApiDisabled() {
        $this->assertEqual($this->Config->getValue('api_disabled'), 1);
        $this->getAction('/api/list_addons');
        $this->assertResponse('503');
    }
}