PHPUnit测试在写入文件时失败

时间:2014-12-10 21:16:03

标签: phpunit travis-ci

我的单元测试在Travis CI上失败,但不在本地。

https://travis-ci.org/humanmade/backupwordpress/jobs/43609663#L362

错误讯息:

1) testBackupPathTestCase::testMergeExistingPath
RuntimeException: Error writing to file. (/tmp/wordpress/wp-content/backupwordpress-   a74dcf0e84-backups/.schedule-test-merge-existing-path-running)

测试在这里:

https://github.com/humanmade/backupwordpress/blob/hmbkp-path/tests/other/testBackupPath.php#L135

以下函数抛出该异常:

/**
 * Set the status of the running backup
 *
 * @access public
 *
 * @param string $message
 *
 * @return void
 */
public function set_status( $message ) {

    $status = json_encode( (object) array(
        'filename' => $this->get_archive_filename(),
        'started'  => $this->get_schedule_running_start_time(),
        'status'   => $message,
    ) );

    if ( false === @file_put_contents( $this->get_schedule_running_path(), $status ) ) {
        throw new RuntimeException( sprintf( __( 'Error writing to file. (%s)', 'backpwordpress' ), $this->get_schedule_running_path() ) );
    }

}

请在此处查看完整课程:

https://github.com/humanmade/backupwordpress/blob/hmbkp-path/classes/class-schedule.php#L838

如何确定CI环境导致的错误或代码中的错误?

0 个答案:

没有答案