dounao5856 2018-02-28 16:54
浏览 72
已采纳

测试方法使用存储失败。 在Laravel中照亮\ Http \ Testing \ imagepng()

Hello, I'm doing TDD to test my development, my tests were passing until I decided to reinstall php to repair the sqlite driver for testing (the main driver is mysql). So when I run my hole suite of tests this error shows in every method that uses the storage:

Error : Call to undefined function Illuminate\Http\Testing\imagepng() {laravel}/framework/src/Illuminate/Http/Testing/FileFactory.php:46 {laravel}/framework/src/Illuminate/Support/helpers.php:1038 {laravel}/framework/src/Illuminate/Http/Testing/FileFactory.php:49 {laravel}/framework/src/Illuminate/Http/Testing/FileFactory.php:31 {laravel}/tests/Feature/FacilityTest.php:38

This one is a method that throws the above error (the line 38 is signaled):

/**
 * @test
 * Test for: a Facility can be registered by an admin.
 */
public function a_facility_can_be_registered_by_an_admin()
{
    /** Given a correct information for a facility */
    \Storage::fake('public');

   // Next line is line 38, the problematic one:
    $data = ["name" => "AAA", 'image' => UploadedFile::fake()->image('aaa.jpg')];

    /** When the request is made by an admin */
    $admin = $this->createUser([], 'admin');
    $response = $this->apiAs($admin, 'POST', '/api/v1/manage/facilities', $data);

    /** Then the facility should be registered */
    $response->assertStatus(Response::HTTP_CREATED);
}

I really don't know why.


If this helps, this is my phpunit file:

phpunit.xml

<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
         backupStaticAttributes="false"
         bootstrap="vendor/autoload.php"
         colors="true"
         convertErrorsToExceptions="true"
         convertNoticesToExceptions="true"
         convertWarningsToExceptions="true"
         processIsolation="false"
         stopOnFailure="false">
    <testsuites>
        <testsuite name="Feature">
            <directory suffix="Test.php">./tests/Feature</directory>
        </testsuite>

        <testsuite name="Unit">
            <directory suffix="Test.php">./tests/Unit</directory>
        </testsuite>
    </testsuites>
    <filter>
        <whitelist processUncoveredFilesFromWhitelist="true">
            <directory suffix=".php">./app</directory>
        </whitelist>
    </filter>
    <php>
        <env name="APP_ENV" value="testing"/>
        <env name="CACHE_DRIVER" value="array"/>
        <env name="SESSION_DRIVER" value="array"/>
        <env name="QUEUE_DRIVER" value="sync"/>
        <env name="DB_CONNECTION" value="sqlite"/>
    </php>
</phpunit>

  • 写回答

1条回答 默认 最新

  • doubiao7267 2018-03-01 19:58
    关注

    Whatever is executing your tests needs to have the PHP GD extension

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 如何将下列的“无限压缩存储器”设计出来
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭