0
我對嘲笑和phpunit測試很新穎。嘲笑應該接收類型 - >獲取對象
我創建了一個測試來檢查是否有東西寫入數據庫。我使用教義和我創建了我的doctrine_connection和我的doctrine_manager模擬對象。
一切正常,但我想得到給定的參數來檢查它與assertEqual。
現在即時通訊執行以下操作:
require_once "AbstractEFlyerPhpUnitTestCase.php";
class test2 extends AbstractEFlyerPhpUnitTestCase {
public function getCodeUnderTest() {
return "../php/ajax/presentations/add_presentation.php";
}
public function testingPresentationObject()
{
// prepare
$_REQUEST["caption"] = "Testpräsentation";
$_SESSION["currentUserId"] = 1337;
$this->mockedUnitOfWork->shouldReceive('saveGraph')->with(\Mockery::type('EFPresentation'));
$this->mockedUnitOfWork->shouldReceive('saveGraph')->with(\Mockery::type('EFSharedPresentation'));
$this->mockedDoctrineConnection->shouldReceive('commit');
//run
$this->runCodeUnderTest();
global $newPresentation;
global $newSharedPresentation;
// verify
$this -> assertEquals($newPresentation->caption,$_REQUEST["caption"]);
$this -> assertEquals($newSharedPresentation->userId,$_SESSION["currentUserId"]);
}
}
saveGraph越來越的EFPresentation對象。我想要的是對象。
我想assertEqual EFPresentation->標題,但從給定的對象給參數。現在我使用在add_presentation中創建的EFPresentation->標題。
謝謝。有效 :) – kovogel