Akelos Framework v1 forum archive. This forum is no longer maintained. To report bugs please visit https://github.com/akelos/akelos/issues
    • CommentAuthoralake
     

    PHP has a bug: http://bugs.php.net/bug.php?id=19022 The symptom showed after a unit test:

    PHP Warning:  Unknown: open(/var/lib/php/session/sess_14m93icat7434o2tkpe3mntpn4, O_RDWR) failed:  
    Permission denied (13) in Unknown on line 0
    
    Warning: Unknown: open(/var/lib/php/session/sess_14m93icat7434o2tkpe3mntpn4, O_RDWR) failed: 
    Permission denied (13) in Unknown on line 0
    PHP Warning:  Unknown: Failed to write session data (files). Please verify that the current setting of
    session.save_path is correct (/var/lib/php/session) in Unknown on line 0
    
    Warning: Unknown: Failed to write session data (files). Please verify that the current setting of 
    session.save_path is correct (/var/lib/php/session) in Unknown on line 0
    

    I have verified that all of my PHP settings are correct. They have not changed since I began to use Akelos and they started appearing sometime after I began unit testing.

    The workarounds for this bug seem to include making certain that one does not code session_id("");

    One poster on the PHP forum said, "So I looked into that, and it turns out PHP fails to delete cookies. I think there is a bug with the delete cookie functions...you might want to check into that. To solve this, instead of deleting the cookies, I just set them to -1, and then checked if they were -1, and if so, treated them as if they weren't there."

    I think that this may be a workaround that must be coded in Akelos itself, not in an Akelos app. Am I correct or not?

    • CommentAuthoralake
     

    There are two reasons for the PHP session errors when doing functional testing. I believe that both of them must be handled from within Akelos.define('AK_SESSION_HANDLER', 1); This define, in config/config.php, specifies that the system use a database table, which is automatically created in the development and production databases. It is not created in the test database. It is not particularly advantageous to have sessions maintained in a database while testing, so perhaps specifying database handling should be ignored during functional testing.

    PHP Warning: Unknown: open(/var/lib/php/session/sess_14m93icat7434o2tkpe3mntpn4, O_RDWR) failed: Permission denied (13) in Unknown on line 0 This message refers to a directory that is accessible to Apache, but not to a user. This is OK when running from a browser, but when I run a test from a command line window, Akelos' attempt to write session information to this directory is going to have a problem. One work-around, which I've not tried, would be to use root to change the permissions on that directory so that I can write to it, but because I don't understand the internal workings of PHP and sessions, I don't know what ramifications that might have outside of my Akelos project. Another work-around would be to change php.ini to write session files to a directory inside of /home/mine. Again, it seems that one should not change system configuration for one application.

    These problems also explain why my functional test may be failing. Because functional testing involves navigation, it seems that session failure would explain why I get a response code of 500 when I expect a 200.

    Do you other members of the community agree or disagree?

    •  
      CommentAuthorbermi
     

    Alake,

    When you run functional tests calling the controller emulates a browser and performs a normal request, so I don't get the user/permission problem.

    Can you run?

    ./script/test unit/lib/AkActionController.php
    

    (you might need to create an application including dependencies using the "-deps" flasg.

    Try to run those tests. If they fail get into

    /tests/unit/lib/AkActionController/_locale_detection.php
    

    and try debugging the URL at

    Ak::trace(AK_TESTING_URL.'/locale_detection');
    

    with your browser.

    • CommentAuthoralake
     

    I did need to create an application including dependencies. I had difficulty because the --dependencies flag had to go after the application path on the create command line, which is not what was displayed when I put -deps before the application path.

    Anyhow, the tests did fail

    I changed _locale_detection.php to look like this:

    function test_detect_default_language()
    {
        Ak::trace(AK_TESTING_URL.'/locale_detection');
        $this->addHeader('Accept-Language: es,en-us,en;q=0.5');
        $this->get(AK_TESTING_URL.'/locale_detection/get_language');
        $this->assertTextMatch('es'); 
    }
    

    The test was:

    $ ./script/test unit/lib/AkActionController.php
    Akelos Framework Action Controller Tests
    ----------------
      ---> http://alan.lakeinfoworks.com/framework_tests/functest/test/fixtures/public/locale_detection
    ----------------
    1) Pattern [/^es$/] not detected in [String: en] at     [/home/alan/develop/php/functest/test/unit/lib/AkActionController/_locale_detection.php line 29]
        in test_detect_default_language
        in _AkActionController_locale_detection
        in /home/alan/develop/php/functest/test/unit/lib/AkActionController/_locale_detection.php
    

    I've listed only the first error. Assuming that the error is mine, let me tell you exactly what I've done in the setup: In config/config.php, I have defined('AK_TESTING_URL') ? null : define('AK_TESTING_URL', 'http://alan.lakeinfoworks.com/framework_tests/functest/test/fixtures/public'); Thinking that this might be wrong, I also tried // defined('AK_TESTING_URL') ? null : define('AK_TESTING_URL', 'http://alan.lakeinfoworks.com/functest/');, which doesn't work as well as the first one. Further,

    * I created the application in /home/alan/develop/php/functest
    * My docroot (a virtual server) is /home/alan/www/html.
    * I have a link from /home/alan/www/html/framework_tests/functest/test/fixtures/public to /home/alan/develop/php/functest/public.
    * I have another link from /home/alan/www/html/functest to /home/alan/develop/php/functest/public/
    

    Because I'm not sure what you are asking for, I created still another link in my docroot: locale_detection -> /home/alan/develop/php/functest/test/unit/lib/AkActionController/_locale_detection.php and executed it from my browser. I just got a listing of the file.

    •  
      CommentAuthorbermi
     

    What error you get in your browser when accessing?

    http://alan.lakeinfoworks.com/framework_tests/functest/test/fixtures/public/locale_detection
    

    This relly seems like a web server miss-configuration.

    • CommentAuthoralake
     

    No error! :-) I got

    Hello from LocaleDetectionController
    
    •  
      CommentAuthorbermi
     

    Really strange. Seems like requests from PHP make your webserver run with different permissions. Thats weird.

    Could you submit a ticket with the failing test cases? Please include your environment details on the ticket.

    That way we might be able to reproduce the bug.