-1

我正在用 yii 框架做一个教程应用程序。当我尝试运行单元测试时,我在命令行中收到此错误

Parse error: syntax error, unexpected T_DOUBLE_ARROW in /Applications/MAMP/htdocs/trackstar/protected/tests/unit/ProjectTest.php on line 11

这是我的代码。我没有在我的代码中发现问题。任何人都可以帮忙吗?

class ProjectTest extends CDbTestCase
{
    public function testCRUD()
    {
        //Create a new project
        $newProject=new Project;
        $newProjectName = 'Test Project 1';
        $newProject->setAttributes(
                array(
                'name' => $newProjectName,
                'description' => 'Test project number one',
                'create_time' => '2010-01-01 00:00:00',
                'create_user_id' => 1,
                'update_time' => '2010-01-01 00:00:00',
                'update_user_id' => 1,
                )
                );
                $this->assertTrue($newProject->save(false));
    }
}
4

1 回答 1

3

在您的“数组”关键字之前有某种不可打印的字符,只需删除那个就可以了

class ProjectTest extends CDbTestCase
{
    public function testCRUD()
    {
        //Create a new project
        $newProject=new Project;
        $newProjectName = 'Test Project 1';
        $newProject->setAttributes(
                array(
                'name' => $newProjectName,
                'description' => 'Test project number one',
                'create_time' => '2010-01-01 00:00:00',
                'create_user_id' => 1,
                'update_time' => '2010-01-01 00:00:00',
                'update_user_id' => 1,
                )
                );
                $this->assertTrue($newProject->save(false));
    }
}

你不会看到区别,但它就在那里

于 2012-09-25T21:32:45.720 回答