【问题标题】:Classes don't seem to load while running tests运行测试时类似乎没有加载
【发布时间】:2014-11-11 09:49:03
【问题描述】:

我是 Laravel 和 PhpUnit 的新手,我正在尝试在 \App\Musibits 目录中的自定义类上运行位于 \App\Tests\Unit 文件夹中的一些测试。

当我在 \App\Tests\Unit 目录中运行 phpunit 时,我得到以下信息:

Fatal error: Class 'Tonality' not found in C:\Program Files (x86)\EasyPHP-DevServer-14.1VC11\data\localweb\musibits\app\tests\TonalityTest.php on line 8

Tonality.php 包含我的课程,位于 \App\Musibits 目录中

我阅读了很多关于自动加载和引导的帖子,但我似乎无法让它工作:-(

这是我的 composer.json

{
    "name": "laravel/laravel",
    "description": "The Laravel Framework.",
    "keywords": ["framework", "laravel"],
    "license": "MIT",
    "require": {
        "laravel/framework": "4.2.*"
    },
    "require-dev": {
        "phpunit/phpunit": "3.7.*"
    },
    "autoload": {
        "classmap": [
            "app/commands",
            "app/controllers",
            "app/models",
            "app/database/migrations",
            "app/database/seeds",
            "app/tests/TestCase.php",
            "app/musibits",
            "app/tests"
        ]
    },
    "scripts": {
        "post-install-cmd": [
            "php artisan clear-compiled",
            "php artisan optimize"
        ],
        "post-update-cmd": [
            "php artisan clear-compiled",
            "php artisan optimize"
        ],
        "post-create-project-cmd": [
            "php artisan key:generate"
        ]
    },
    "config": {
        "preferred-install": "dist"
    },
    "minimum-stability": "stable"
}

Laravel 自带了三个 autoload 文件,一个给 composer,一个给 phpunit,一个给 Laravel,我没改过。

任何线索将不胜感激。

谢谢,

菲尔

【问题讨论】:

    标签: laravel laravel-4 phpunit autoload


    【解决方案1】:

    你可能应该跑

    composer dump-autoload
    

    生成新的类映射

    【讨论】:

    • ...为此浪费了很多时间。非常感谢!我还不能投票给你作为答案。祝你有美好的一天!
    • 对不起,我也是 StackOverFlow 的新手 :-)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-09-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多