Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Issues with built in Unit Tests and Base URL
  • Ive modified my Config file to use a BaseURL
    Now when I run the Unit test via oil I get:
    <code>
    There were 2 failures: 1) Fuel\Core\Test_Html::test_anchor
    Failed asserting that two strings are equal.
    --- Expected
    +++ Actual
    @@ @@
    -'<a href="controller/method">Method</a>'
    +'<a href="http://fule.lo/controller/method">Method</a>' XXX/projects/radar_fuel/fuel/core/tests/html.php:85 2) Fuel\Core\Test_Html::test_img
    Failed asserting that two strings are equal.
    --- Expected
    +++ Actual
    @@ @@
    -'<img src="image.png" alt="image" />'
    +'<img src="http://fule.lo/image.png"; alt="image" />' xxx/projects/radar_fuel/fuel/core/tests/html.php:130 FAILURES!
    Tests: 299, Assertions: 254, Failures: 2.
    </code> Any thoughts?
  • Don't know exactly what you modified, and where (I hope not in core code), but the end result is that base URL's are forcibly inserted, which obviously changes the workings of some methods, and therefore the tests fail.
  • Thanks for the reply. The only modification was to the config file in app/config/development
    <?php
    /**
     * Fuel is a fast, lightweight, community driven PHP5 framework.
     *
     * @package    Fuel
     * @version    1.0
     * @author     Fuel Development Team
     * @license    MIT License
     * @copyright  2010 - 2012 Fuel Development Team
     * @link       [url=http://fuelphp.com]http://fuelphp.com[/url]
     */
    
    return array(
    
     /**
      * base_url - The base URL of the application.
      * MUST contain a trailing slash (/)
      *
      * You can set this to a full or relative URL:
      *
      *     'base_url' => '/foo/',
      *     'base_url' => 'http://foo.com/'
      *
      * Set this to null to have it automatically detected.
      */
     'base_url'  => 'http://fule.lo/',
    

    I would have expected UnitTest to accept changes in the config file (as by definition config values are variable). Is there something I am missing there?
  • I don't think this is something to worry about. Most of the methods in the FuelPHP core can be influenced by configuration. And it looks like in some of the test teh configuration isn't set to a known value before running the tests, but depend on defaults instead. Which goes horribly wrong if you change them. As you don't change anything in the core as a user (I hope not), it's pretty pointless to run the core tests yourself, the code comes tested, and once installed it will not change anymore.
  • Thanks Harro and I appreciate the input. Given that my current code is Non-Production it is easy enough to ignore the core.
    But once I move the code to production I may need to revisit.
    Does it make sense to add this as a bug or is it such a low priority (given we are talking about an improvement to the tests, not the code) that it doesn't make sense to add it? thanks again for your help
  • You could, but I don't think we're going to spend any time on it. The focus is on 2.0 now, which will be completely unit tested, and we have to make sure we don't make any assumptions on the environment when we run them.

Howdy, Stranger!

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

In this Discussion