PHPUnit Failed to Open Stream: No such file or directory

Hi everyone,

I am relatively new to PHP and new to Yii so apologies if this is a remedial question. I am utilizing PHPUnit to test my code as I develop and have recently implemented fixtures. When I run PHPUnit I receive the following error. “include(user_update_id.php): failed to update stream: no such file or directory”. I should not have a user_update_id.php file as this is an attribute of my project object and not it’s own php file.

I am at a loss for how to track down what is causing this failure and am looking for techniques or assistance on tracking down the root cause. I had a similar problem with another attribute that was due to not closing out my ‘’ properly for one of the attributes. I’ve gone through all of the source code for my project and validated that all references to user_update_id are properly ‘’.

Any insight on where I should be looking or what I should be looking for would be greatly appreciated.

Thanks,

Bill

OS: Ubuntu 11:04

PHP: 5.4

Yii: 1.1

MySql: 5.4

PHPUNIT: 3.5

Everything is latest versions as they have been installed in the last week.

you are not alone.

I can’t test YII app too but I got different error message.

Can you identify what file is throwing this error? if so, please provide its contents along with a stack trace so we can analyse where it is going wrong.

Thanks! Here is the error message provided by phpunit

  1. ProjectTest::testCreate

include(update_user_id.php): failed to open stream: No such file or directory

/var/www/yii/framework/YiiBase.php:396

/var/www/yii/framework/YiiBase.php:396

/var/www/yii/framework/YiiBase.php:291

/var/www/yii/framework/validators/CValidator.php:166

/var/www/yii/framework/base/CModel.php:283

/var/www/yii/framework/base/CModel.php:257

/var/www/yii/framework/base/CModel.php:548

/var/www/yii/framework/base/CModel.php:467

/var/www/trackstar/protected/tests/unit/ProjectTest.php:70

I’ve included ProjectTest.php as the rest of the code is from the framework and is not modified. Let me know if you are looking for something else. Thanks!

<?php

class ProjectTest extends CDbTestCase

{

public &#036;fixtures=array


(


    'projects'=&gt;'Project',


);





public function testCRUD()


{


    //Create a new project


    &#036;newProject=new Project;


    &#036;newProjectName = 'Test Project 1';


    &#036;newProject-&gt;setAttributes(


            array(


                'name'=&gt;&#036;newProjectName,


                'description'=&gt; 'Test project number one',


                'create_time'=&gt; '2010-01-01 00:00:00',


                'create_user_id'=&gt; 1,


                'update_time'=&gt; '2010-01-01 00:00:00',


                'update_user_id'=&gt; 1,


            )


        );


    &#036;this-&gt;assertTrue(&#036;newProject-&gt;save(false));





    //READ back the newly created project


    &#036;retrievedProject=Project::model()-&gt;findByPk(&#036;newProject-&gt;id);


    &#036;this-&gt;assertTrue(&#036;retrievedProject instanceof  Project);


    &#036;this-&gt;assertEquals(&#036;newProjectName,&#036;retrievedProject-&gt;name);








    //UPDATE the newly created project


    &#036;updatedProjectName = 'Updated Test Project 1';


    &#036;newProject-&gt;name = &#036;updatedProjectName;


    &#036;this-&gt;assertTrue(&#036;newProject-&gt;save(false));





    //read back the record again to ensure the update worked


    &#036;updatedProject=Project::model()-&gt;findByPk(&#036;newProject-&gt;id);


    &#036;this-&gt;assertTrue(&#036;updatedProject instanceof  Project);


    &#036;this-&gt;assertEquals(&#036;updatedProjectName,&#036;updatedProject-&gt;name);





    //DELETE the project


    &#036;newProjectID = &#036;newProject-&gt;id;


    &#036;this-&gt;assertTrue(&#036;newProject-&gt;delete());


    &#036;deletedProject=Project::model()-&gt;findByPk(&#036;newProjectID);


    &#036;this-&gt;assertEquals(NULL,&#036;deletedProject);


}

public function test_Read()

{


    &#036;retrievedProject = &#036;this-&gt;projects('project1');


    &#036;this-&gt;assertTrue(&#036;retrievedProject instanceof  Project);


    &#036;this-&gt;assertEquals('Test Project 1',&#036;retrievedProject-&gt;name);


}

public function testCreate()

{


    //Create a new Project


    &#036;newProject =new Project;


    &#036;newProjectName = 'Test Project Creation';


    &#036;newProject-&gt;setAttributes(


        array(


            'name'=&gt; &#036;newProjectName,


            'description'=&gt; 'This is a test for new project creation',


            'create_time'=&gt; '2009-09-09 00:00:00',


            'create_user_id'=&gt; 1,


            'update_time' =&gt; '2009-09-09 00:00:00',


            'update_user_id'=&gt; 1,


        )


    );


    &#036;this-&gt;assertTrue(&#036;newProject-&gt;save(false));


    //READ back the newly created Project to ensure the creation worked


    &#036;retrievedProject=Project::model()-&gt;findByPk(&#036;newProject-&gt;id);


    &#036;this-&gt;assertTrue(&#036;retrievedProject instanceof Project);


    &#036;this-&gt;assertEquals(&#036;newProjectName,&#036;retrievedProject-&gt;name);


}








public function testRead()


{


    &#036;retrievedProject = &#036;this-&gt;projects('project1');


    &#036;this-&gt;assertTrue(&#036;retrievedProject instanceof  Project);


    &#036;this-&gt;assertEquals('Test Project 1',&#036;retrievedProject-&gt;name);


}


public function testUpdate()


{


    &#036;project = &#036;this-&gt;projects('project2');


    &#036;updatedProjectName = 'Updated Test Project 2';


    &#036;project-&gt;name = &#036;updatedProjectName;


    &#036;this-&gt;assertTrue(&#036;project-&gt;save(false));


    &#036;updatedProject=Project::model()-&gt;findByPk(&#036;project-&gt;id);


    &#036;this-&gt;assertTrue(&#036;updatedProject instanceof  Project);


    &#036;this-&gt;assertEquals(&#036;updatedProjectName,&#036;updatedProject-&gt;name);


}

public function testDelete()

{

&#036;project = &#036;this-&gt;projects('project1');


&#036;savedProjectId = &#036;project-&gt;id;


&#036;this-&gt;assertTrue(&#036;project-&gt;delete());


&#036;deletedProject=Project::model()-&gt;findByPk(&#036;savedProjectId);


&#036;this-&gt;assertEquals(NULL, &#036;deletedProject);

}

}

?>

bump - any thoughts on this one? Suggestions on tools to try for debugging are also extremely appreciated.

There’s probably something wrong with the validator rule(s) for update_user_id in the Project model.

/Tommy

Sorry, I know this is an old topic, but I just had the same problem, and it was indeed related to validation rules. So I’ll just answer for future reference, if someone finds this thread. The rules method in the model class takes a comma separated list of attributes as the first array value, and only the function values (for lack of a btter term) like ‘required’, ‘safe’ etc. are separate values. So I had in my rules method:


array('name', 'description', 'required'),

when it must be


array('name, description', 'required'),

The first represenation makes Yii look for a ‘description’ validation class, which is why the error message may be strange at first glance.