Akelos Framework v1 forum archive. This forum is no longer maintained. To report bugs please visit https://github.com/akelos/akelos/issues
    • CommentAuthorsuthern
     
    Has anyone else run into this? The record shows up in the database but save() returns false.

    Shouldn't save either SAVE (and return true), or NOT SAVE (and return false)? $object->getFullErrorMessages() returns false as does $object->hasErrors(). Any tips on where to begin debugging would be appreciated!
    Thanks!
    •  
      CommentAuthorbermi
     

    That's an odd behaviour. Any unit test we can look at?

    • CommentAuthorsuthern
     
    While trying to run a model test I ran into some odd behavior. The steps are below:

    1) Running this: ./script/test unit/app/models/part
    Produced this: Notice: Undefined variable: testing_database in /home/sambaserve/web/apps/inventory/config/environments/testing.php on line 9

    So I look at testing.php and it contains this line: $GLOBALS['ak_test_db_dns'] = isset($dsn) ? $dsn : $testing_database;
    $testing_database is not defined in boot.php or config.php. Where and what should it be defined as? (What an odd sentence!)

    Thanks!
    • CommentAuthorsuthern
     
    Yes, this is the first time I've tried to run unit tests... ;-)
    •  
      CommentAuthorbermi
     

    Your test/ and config/environment are outdated

    On changeset 468 we removed that line from config/environments/testing.php

    Try to update your test and /environment folders in your application with the latest version.

    • CommentAuthorsuthern
     
    Thanks!
    -- To update /environment/*.php I copied the files from the akelos/app/config dir.
    -- How would I go about regenerating all the files inside /test? I'll be happy to do it one controller at a time, but can't figure out how.
    -- I've also updated the /scripts folder. :-)
    •  
      CommentAuthorbermi
     

    In test you just need to update unit.php, app.php and fixtures/app/config

    • CommentAuthorsuthern
     
    test/fixtures/app/config does not exist under /akelos/.
    Ive updated inventory/test/app/config/config.php from /akelos/test/app/config/config.php.
    Now I try to run ./script/test unit/app/models/spots_transfers and my result is:

    Segmentation fault

    I'll hunt around and report back when the Seg fault is out of the way. Thanks for your patience!
    •  
      CommentAuthorbermi
     

    Sorry I should have said test/fixtures/config

    • CommentAuthorsuthern
     

    Ok, I've tracked it down to a strange issue with Ak::make_dir. It goes into an infinite loop and then causes a seg fault. Here's the function:

    function make_dir($path, $options = array())
    {
        error_log("Make_dir path:".var_export($path,TRUE), 1,"suthern101@gmail.com");
        error_log("Make_dir options:".var_export($options,TRUE), 1,"suthern101@gmail.com");
        $default_options = array(
        'ftp' => defined('AK_UPLOAD_FILES_USING_FTP') && AK_UPLOAD_FILES_USING_FTP,
        'base_path' => AK_BASE_DIR
        );
        $options = array_merge($default_options, $options);
        $path = trim(str_replace($options['base_path'], '',$path),DS);
    
        if($options['ftp']){
            require_once(AK_LIB_DIR.DS.'AkFtp.php');
            $path = trim(str_replace(array(DS,'//'),array('/','/'),$path),'/');
            return AkFtp::make_dir($path);
        }else{
            $path = $options['base_path'].DS.$path;
            if (!file_exists($path)){
                Ak::make_dir(dirname($path), $options);
                return mkdir($path);
            }
        }
        return false;
    }
    

    Note my two error_log calls.. My e-mail box was flooding with messages until I hit ctrl-c to quite the ./script/test process. Here are the two arguments that are being passed to it.

    $path = NULL
    $options = array (
      'ftp' => false,
      'base_path' => '/home/sambaserve/web/apps/inventory/test/tmp',
     )
    
    • CommentAuthorsuthern
     

    make_dir is being called from Ak::file_put_contents, which is called from AkInstaller::SetInstalledVersion, which is called from AkInstaller::getInstalledVersion, which is called from AkInstaller::_upgradeOrDowngrade, which is called from AkInstall::install which is called from AkUnitTest::installAndIncludeModels which is called from function test_setup inside /test/unit/app/models/spots_transfers.php.

    • CommentAuthorsuthern
     

    I've gotten around the seg fault by manually creating /test/tmp/install_versions/ and thus no segfault anymore.

    Here's the next problem:

      [me@server]$ ./script/test unit/app/models/spots_transfers
      SpotsTransfersTestCase
      OK
      Test cases run: 1/1, Passes: 0, Failures: 0, Exceptions: 0
          /home/sambaserve/web/apps/inventory/test/unit/app/models/spots_transfers.php
    
      Fatal error: Cannot redeclare class SpotsTransfersTestCase in       
      /home/sambaserve/web/apps/inventory/test/unit/app/models/spots_transfers.php on line 18
    

    With something VERY simple in the spots_transfers.php file:

    <?php
    // To run this test calling ./script/test unit/app/models/spots_transfers   // More about testing at         
    http://wiki.akelos.org/testing-guide
    
    class SpotsTransfersTestCase extends AkUnitTest
    {
    /*    
    
        function test_setup()
        {
            $this->installAndIncludeModels('SpotsTransfers');
        }
    
        function test_SpotsTransfers()
        {
            $this->assertTrue(false,'Unit test for SpotsTransfers not implemented');
        }
    */    
    }
    
    ?>
    

    Such a simple test (It's even commented out!!), and I still get the error. Is this normal?

    • CommentAuthorsuthern
     

    Thanks for the svn update to fix the recursive make_dir bug. You're fast!

    •  
      CommentAuthorbermi
     

    Try

    ./script/test model spots_transfers
    

    or

    php ./test/unit/app/models/spots_transfers
    
    •  
      CommentAuthorbermi
     

    Thanks to Kaste!

    • CommentAuthorKaste
     

    solved the recursive call in [561]

    can't reproduce the second failure though.

    • CommentAuthorKaste
     

    oops, we're all in now.

    • CommentAuthorsuthern
     

    I'm working on a unit test, but now after doing an svn revert and update I'm getting this:

    [me@host]$ ./script/test model SpotsTransfers
    PHP Warning:  Call-time pass-by-reference has been deprecated - argument passed by value;  If you would like to pass it by reference, modify the declaration of [runtime function name]().  If you would like to enable call-time pass-by-reference, you can set allow_call_time_pass_reference to true in your INI file.  However, future versions may not support this any longer.  in /home/sambaserve/web/akelos/lib/AkObject.php on line 67
    Content-type: text/html
    X-Powered-By: PHP/4.3.9
    

    I've defined ALLOW_CALL_TIME_PASS_REFERENCE as true in both /config/config.php and /test/fixtures/config/config.php. Need I define it somewhere else? Also note that when I do phpinfo, it tells me I'm running 5.2.something. But X-Powered-By: says 4.3.9! Could it be that running ./script uses a different php engine than the xampp install? Hmm...

    • CommentAuthorbjmg
     

    I am quite sure that your command line php is not the same as the web php. You can check that by running "php -v" on the shell.

    Hope this helps.

    • CommentAuthorsuthern
     

    Yup, you are right. php -v tells me it's running php 4.3.9.

    I also solved the strange save() behavior by changing my beforeSave() function into a afterValidation() function. Now I've just got to figure out how to change running php engine to point at lampp's php executable (so the versions match).

    Thank you all for your help!

    • CommentAuthorbjmg
     

    Changing the default search path should be easy: "export PATH=/path/to/php5/bin:$PATH" Another trick would be to change the first line in ./script to "#!/path/to/php5/bin/php5" Just try it.

    • CommentAuthorsuthern
     

    I modified ./script/test for now. Thanks again!