Quantcast
Channel: Yii Framework Forum
Viewing all articles
Browse latest Browse all 18717

Yii unit testing: phpunit + bootstrap extension + getBasePath

$
0
0
I have a Yii project using the latest bootstrap extension (which might not be important), and while trying to run unit tests, it throwed me an error:

PHP Fatal error:  Uncaught exception 'CException' with message 'CAssetManager.basePath "/usr/bin/assets" is invalid. Please make sure the directory exists and is writable by the Web server process.' in /Users/belerophon/Documents/blah/repos/blah2/libs/yii/yii-1.1.11.58da45/framework/web/CAssetManager.php:134
Stack trace:
#0 /Users/belerophon/Documents/blah/repos/blah2/libs/yii/yii-1.1.11.58da45/framework/web/CAssetManager.php(119): CAssetManager->setBasePath('/usr/bin/assets')
#1 /Users/belerophon/Documents/blah/repos/blah2/libs/yii/yii-1.1.11.58da45/framework/web/CAssetManager.php(240): CAssetManager->getBasePath()
#2 /Users/belerophon/Documents/blah/repos/blah2/libs/bootstrap/yii-bootstrap-1.0.0.alpha5.r280/components/Bootstrap.php(328): CAssetManager->publish('/Users/beleroph...', false, -1, false)
#3 /Users/belerophon/Documents/blah/repos/blah2/libs/bootstrap/yii-bootstrap-1.0.0.alpha5.r280/components/Bootstra in /Users/belerophon/Documents/blah/repos/blah2/libs/yii/yii-1.1.11.58da45/framework/web/CAssetManager.php on line 134


I don't understand why getBasePath is returning "/usr/bin", when running the test code.
Btw, I ran it like this:
cd protected/tests
phpunit unit/UserTest.php


I don't know if this is worth mentioning, but in my directory structure I'm using some symlinks. I have this:
|-- libs
|   |-- bootstrap
|   |   |-- latest -> yii-bootstrap-1.0.0.alpha5.r280
|   |   |-- yii-bootstrap-0.10.1.beta.r254
|   |   `-- yii-bootstrap-1.0.0.alpha5.r280
|   |-- yii
|   |   |-- latest -> yii-1.1.11.58da45
|   |   |-- yii-1.1.10.r3566
|   |   `-- yii-1.1.11.58da45
`-- src
    `-- project.com
        |-- images
        |-- index-test.php
        |-- index.php
        |-- protected
        |   |-- tests
        |   |   |-- WebTestCase.php
        |   |   |-- bootstrap.php
        |   |   |-- fixtures
        |   |   |-- functional
        |   |   |-- phpunit.xml
        |   |   `-- unit
        |   |-- yiic
        |   |-- yiic.bat
        |   `-- yiic.php
        |-- temp.html
        `-- themes
            `-- classic
                `-- views


Notice the symlinks on the lib's folders.

So, for example, my index.php looks like this:
<?php

// change the following paths if necessary
$yii=dirname(__FILE__).'/../../libs/yii/latest/framework/yii.php';
$config=dirname(__FILE__).'/protected/config/main.php';

// remove the following lines when in production mode
defined('YII_DEBUG') or define('YII_DEBUG',true);

// specify how many levels of call stack should be shown in each log message
defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL',3);

require_once($yii);
Yii::createWebApplication($config)->run();



I'm working with the latest Yii release, in a Mac OSX Lion, php 5.3.10
For now, I'm simply unable to run tests with phpunit.

Can someone help me here?

Thanks in advance!
André

Viewing all articles
Browse latest Browse all 18717


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>