While the main point of this blog post about testing file uploads is to describe how to write PHPT tests, it shows how to integrate them into PHPUnit at the end of the post. In short, you pass the absolute path to the .phpt
file to the parent constructor.
<?php
require_once 'PHPUnit/Extensions/PhptTestCase.php';
class UploadExampleTest extends PHPUnit_Extensions_PhptTestCase {
public function __construct() {
parent::__construct(__DIR__ . '/upload-example.phpt');
}
}
Alternatively, you can use the PHPUnit_Extensions_PhptTestSuite
class, that takes a directory as its first constructor argument and then searches for all *.phpt files within this directory.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…