Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
PHP Unit and the Config Class.
  • I have some unit test which have been using hardcoded RULs to perform Http requests using the Request class. We are almost done with the first milestone of the project, and I decided to move those hardcoded URLs to a config file in fuel/app/config/phpunit.php I have been using the Config class to get the values inside my new file, but for some reason it seems like is not returning anything at all! here is what I'm doing (in a nutshell):
    /**
     * @group Api
     */
    class Test_Controller_Api extends TestCase
    {
        protected static $url;
        
        public static function setUpBeforeClass() 
        {
            \Config::get('phpunit', true);
            self::$url = \Config::get('phpunit.development.api_base_url') . 
                         \Config::get('phpunit.v1_uri');
    
        }
    
        public function test_print_url() 
        {        
            echo self::$url . 'users/list.json';
        }
    }
    

    the config file looks like this
    return array(
     'development' => array(
            'api_base_url' => 'http://localhost/',
        ),
        'v1_uri' => 'api/v1/',
    );
    

    when I run
    oil test --group=Api
    
    I get a bunch of errors because my url is incorrect, and the "echo" prints only "users/list.json" Any ideas what I may be doing wrong? Thank you, Onema

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!