Zend_Test_PHPUnit_ControllerTestC
全部标签 目前我正在为一个框架编写测试,我们通常在测试失败时使用自定义错误消息,添加一些有用的调试信息:$this->assertEquals($check,$result,'Class::methodreturnedthewrongresultwithargumentXXX');但是我希望在检查函数调用时自定义错误消息:$mock->expects($this->any())->method('foobar')->with($this->equals('dummy'));当上述断言不成立时,我得到标准消息。我在PhpUnit文档中进行了搜索,但找不到自定义错误消息的方法,我是否遗漏了任何内容?
我有这样一个代码:publicfunctionone(){try{$this->two();}catch(Exception$E){$this->three();}}我如何测试调用了$this->three()函数?我尝试“按代码模拟”$this->two()并抛出错误而不是它的原始代码,但最终错误被phpunit本身捕获。尝试了setExpectedException,但它也没有解决问题-catch再次在phpunit中运行,只是被忽略了。函数$this->three()在这两种情况下都没有被调用。谢谢! 最佳答案 问题是所描述的
我正在使用具有以下设置的Ubuntu15.04-64位:ApacheServerversion:Apache/2.4.10(Ubuntu),Serverbuilt:Jul24201517:25:18PHPPHP5.6.4-4ubuntu6.2(cli)(built:Jul2201515:29:28)Copyright,(c)1997-2014ThePHPGroupZendEnginev2.6.0,Copyright(c),1998-2014ZendTechnologieswithZendOPcachev7.0.4-dev,Copyright,(c)1999-2014,byZendTec
我正在使用Codeigniter3框架和一个phpunit包ci-phpunit-test.我在启用了zend调试器的zend服务器上运行php。我的phpunit.xml文件在那里:././_ci_phpunit_test/../controllers../models我使用带有绿色线条和破折号的图标来运行代码覆盖执行,这会运行以下命令:"C:\ProgramFiles(x86)\Zend\ZendServer\bin\php.exe"-dzend_debugger.enable_coverage=1C:/Users/NICOLAS/AppData/Local/Temp/ide-ph
我正在尝试使用它们之间的共享session运行多个测试,从登录开始。'chrome','sessionStrategy'=>'shared');publicfunctionsetUp(){$this->webDriver=RemoteWebDriver::create($this->host,$this->browser);}publicfunctiontearDown(){$this->webDriver->quit();}我的第一个测试是登录,效果很好:publicfunctiontestLogin(){$this->webDriver->get('http://localhost
我使用以下方法在我的PHPUnit测试中分派(dispatch)Slim应用程序的路由:protectedfunctiondispatch($path,$method='GET',$data=array()){//Prepareamockenvironment$env=Environment::mock(array('REQUEST_URI'=>$path,'REQUEST_METHOD'=>$method,));//Preparerequestandresponseobjects$uri=Uri::createFromEnvironment($env);$headers=Header
对于一个包含很多实体的大型项目,我编写了一个save()通用方法。此方法存储在抽象服务中,并在所有项目中用于保存实体状态。AbstractService::save()看起来像这样:publicfunctionsave($entity){$transactionStarted=$this->beginTransaction();try{$action=$entity->getId()?self::UPDATE:self::CREATION;$this->getEventManager()->trigger('save.pre',$entity,['action'=>$action]);
我在使用phpunit命令测试我的应用程序时遇到上述错误。publicfunctiontestProductCreationFailsWhenNameNotProvided(){$product=factory(\App\Product::class)->make(['name'=>'']);$this->post(route('api.products.store'),$product->jsonSerialize())->seeJson(['name'=>['Thenamefieldisrequired.']])/*line86*/->assertResponseStatus(42
我正在测试一个旨在测试用户是否拥有给定电子邮件的对象。因此,在调用“tryEmail”方法时,它会向给定的电子邮件地址发送一strip有确认链接的消息。我的测试看起来像这样:publicfunctiontestSendingWasSuccessful(){$confirmationObject=$this->getMock('LT\EmailConfirmation\Model\ConfirmationObjectInterface');$testType='test.type';$testEmail='test@example.com';$testData=[];//EmailTes
我正在尝试将预先计算的测试用例数组发送到模拟中,以便在连续调用时返回-类似于map函数。但是它需要一个参数列表,而不是一个数组。我的数组已经由夹具生成器生成,并且可能具有可变长度。我想做的是这样的事情,但这当然会导致它在第一次调用时返回整个数组。//Inatestcase:$processorMock->method('process')->willReturnOnConsecutiveCalls($fixtureLoader->getProcessorScenarios()//howtoexplodethis?);//classFixtureLoaderpseudocode:func