我想测试我的服务,这些服务主要由我的控制器调用。 我实现了这个:
class FMaiAffaireServiceTest extends TestCase
{
public function setUp()
{
$this->myService = new FMaiAffaireService();
}
public function listAffairesCountTest()
{
$this->myService->listAffairesCount();
}
}
但PHPUnit在此处无法识别任何测试。我怎么能实现我的小测试:)?感谢。
这是我的功能(我没有提到数据库模拟意图)
class FMaiAffaireService
{
public function __construct(
FMaiAffaireTable $maiAffaireTable
) {
$this->maiAffaireTable = $maiAffaireTable;
}
public function listAffairesCount()
{
return $this->maiAffaireTable->listAffairesCount();
}
}
答案 0 :(得分:2)
PHPUnit将识别以//Upload image
function upload($path,$token,$fb)
{
$image = [
'message' => 'My awesome photo upload example.',
'source' => $fb->fileToUpload($path), // $fb is instance
];
try {
// Returns a `Facebook\FacebookResponse` object
$response = $fb->post('/me/photos', $image, $token);
} catch(Facebook\Exceptions\FacebookResponseException $e) {
echo 'Graph returned an error: ' . $e->getMessage();
exit;
} catch(Facebook\Exceptions\FacebookSDKException $e) {
echo 'Facebook SDK returned an error: ' . $e->getMessage();
exit;
}
$graphNode = $response->getGraphNode();
debug_to_console($graphNode);
echo " \n Photo ID: " . $graphNode['id'];
}
开头的任何public function
作为测试。因此,test
代替listAffairesCountTest
,您的测试需要命名为testListAffairesCount