Codeception handle expected UserException - yii2

Running a function test as below for an application in Yii2 framework.
public function checkEmptyToken2(FunctionalTester $I)
{
$I->amOnRoute('site/verify-email', ['token' => '']);
$I->canSee('Email verify token did not come through for some reason');
}
Results in an error as below.
Codeception PHP Testing Framework v4.2.1
Powered by PHPUnit 8.5.27
Frontend\tests.functional Tests (1) -------------------------------------------------------------------------------------------------------------------------------------------------------------
E VerifyEmailCest: Check empty token2 (0.01s)
-------------------------------------------------------------------------------------------------------------------------------------------------------------
1) VerifyEmailCest: Check empty token2
Test tests/functional/VerifyEmailCest.php:checkEmptyToken2
[yii\base\UserException] Email verify token did not come through for some reason.
You can either copy/paste the verification email again OR
request a new verification email from the Login page.
Scenario Steps:
1. $I->amOnRoute("site/verify-email",{"token":""}) at tests/functional/VerifyEmailCest.php:41
#1 /data/www/frontend/models/VerifyEmailForm.php:38
#2 /data/www/frontend/controllers/SiteController.php:345
#3 frontend\controllers\SiteController->actionVerifyEmail
#4 /data/www/vendor/yiisoft/yii2/base/InlineAction.php:57
#5 /data/www/vendor/yiisoft/yii2/base/Controller.php:178
#6 /data/www/vendor/yiisoft/yii2/base/Module.php:552
#7 /data/www/vendor/yiisoft/yii2/web/Application.php:103
#8 /data/www/vendor/symfony/browser-kit/Client.php:405
#9 Codeception\Module\Yii2->amOnRoute
#10 /data/www/frontend/tests/_support/_generated/FunctionalTesterActions.php:661
Time: 718 ms, Memory: 16.00 MB
There was 1 error:
---------
ERRORS!
Tests: 1, Assertions: 0, Errors: 1.
I expect the error to be exactly that! All I want Codeception to do is to simply ignore it and move on so I can check for the error text in "canSee". I tried using try/catch statement and that results in a different error. Tried using "expectException" and that did not work either.

The codeception module will only handle subclasses of yii\web\HttpException as part of the normal request flow.
If you are throwing a yii\base\UserException then the status code will always be 500 as it is for any other exception.
While I doubt that throwing UserExceptions that do not extend the HttpException the Yii error handler supports it. I'll update the codeception module to support it as well.

Related

Cannot use transfer or send on solidity

I use Ganache, truffle.
I get the following error:
Error: [ethjs-query] while formatting outputs from RPC '{"value":{"code":-32603,"data":{"message":"VM Exception while processing transaction
I have located the problematic piece of code:
bool sent = _sellerAddress.send(_price);
Now, I get the price via the user interaction, and when the price is 0, then the error is not thrown,
unfortunately in the classic case when the _price is no zero, the exception is thrown.
Any suggestions?

Magento 2 : Exception #0 (Exception): Recoverable Error:

I have moved one magento 2 website from one server to another, after configuration, I got below error on category pages:
1 exception(s):
Exception #0 (Exception): Recoverable Error: Argument 1 passed to Mageplaza\Core\Helper\AbstractData::__construct() must be an instance of Magento\Framework\App\Helper\Context, instance of Magento\Framework\ObjectManager\ObjectManager given, called in /SOME_PATH/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php on line 93 and defined in /SOME_PATH/app/code/Mageplaza/Core/Helper/AbstractData.php on line 56
Exception #0 (Exception): Recoverable Error: Argument 1 passed to Mageplaza\Core\Helper\AbstractData::__construct() must be an instance of Magento\Framework\App\Helper\Context, instance of Magento\Framework\ObjectManager\ObjectManager given, called in /SOME_PATH/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php on line 93 and defined in /SOME_PATH/app/code/Mageplaza/Core/Helper/AbstractData.php on line 56
I have tried below things to resolve above:
Reindexing
Re-save category pages from backend
Created new category, and found its page working fine.
It seems there is a problem with database where old category urls need to be reindexed/rewritten or processed some way.
Can anyone help me to resolve this or any guide how I can troubleshoot this further?
Any help is appreciated!
Thanks
Deleting var/di directory resolves the problem. I didn't need to run any CLI command nor I need to do any cache clear stuff!

a session error after updating to laravel 5.4

After updating from laravel 5.3 to 5.4, I encountered an error in vendor. The error is:
Symfony\Component\Debug\Exception\FatalThrowableError: Call to undefined method Illuminate\Session\Store::set() in /var/www/ostadbank.com/vendor/laravel/framework/src/Illuminate/Support/Manager.php:137
But when I go to my error is:
fatal error exception in Manager.php line 137:call to undefined method Illuminate\session\store::set()
I go to manager.php line 137 and I see the line below:
public function __call($method, $parameters) { return $this->driver()->$method(...$parameters); }
I am not sure where to start to modify.
See the screenshots below:
I solve it, for more information read this: https://laravel.com/docs/5.4/upgrade
All calls to the ->set() method should be changed to ->put(). Typically, Laravel applications would never call the set method since it has never been documented within the Laravel documentation. However, it is included here out of caution.

Media wiki merge and delete a user using MergeUser extension

Hi i am trying to install the MergeUser plugin in media wiki. My account is in both sysop and bureaucrat. I have enabled $wgGroupPermissions['bureaucrat']['usermerge'] = true;
When i try to access /Special:UserMerge i get the following error
[70aadcac] /index.php/Special:UserMerge Exception from line 376 of /var/www/plivowiki/includes/SpecialPage.php: Call to undefined method UserMerge::getPageTitle
Backtrace:
#0 /var/www/plivowiki/extensions/UserMerge/UserMerge_body.php(128): SpecialPage->__call(string, array)
#1 /var/www/plivowiki/extensions/UserMerge/UserMerge_body.php(128): UserMerge->getPageTitle()
#2 /var/www/plivowiki/includes/SpecialPage.php(631): UserMerge->execute(NULL)
#3 /var/www/plivowiki/includes/SpecialPageFactory.php(488): SpecialPage->run(NULL)
#4 /var/www/plivowiki/includes/Wiki.php(298): SpecialPageFactory::executePath(Title, RequestContext)
#5 /var/www/plivowiki/includes/Wiki.php(602): MediaWiki->performRequest()
#6 /var/www/plivowiki/includes/Wiki.php(467): MediaWiki->main()
#7 /var/www/plivowiki/index.php(49): MediaWiki->run()
#8 {main}
You need to either upgrade MediaWiki, or downgrade the MergeUser extension. The function SpecialPage::getPageTitle was introduced recently (it was called SpecialPage::getTitle before).
If you can't upgrade MediaWiki to the latest version, a possible patch would be to replace getPageTitle with getTitle in /extensions/UserMerge/UserMerge_body.php, but of there could still be other incompatibilities.
Also, please give the versions of the relevant software and extensions when asking this type of questions, that will make it much easier to give good answers.
Edit: I see now that this has been answered before: UserMerge Error

BeepBeep and ErlyDB integration issue

Further to my adventures with Erlang and ErlyDB. I am attempting to get ErlyDB working with BeepBeep
My ErlyDB setup works correctly when run outside of the BeepBeep environment (see Debugging ErlyDB and MySQL). I have basically take the working code and attempted to get it running inside BeepBeep.
I have the following code in my controller:
handle_request("index",[]) ->
erlydb:start(mysql,Database),
erlydb:code_gen(["thing.erl"],mysql),
NewThing = thing:new_with([{name, "name"},{value, "value"}]),
thing:save(NewThing),
{render,"home/index.html",[{data,"Hello World!"}]};
When I call the URL, the response outputs "Server Error".
There is no other error or exception information reported.
I have tried wrapping the call in try/catch to see if there is an underlying error - there is definitely an exception at the call to thing:new_with(), but no further information is available.
The stacktrace reports:
{thing,new,[["name","value"]]}
{home_controller,create,1}
{home_controller,handle_request,3}
{beepbeep,process_request,4}
{test_web,loop,1}
{mochiweb_http,headers,4}
{proc_lib,init_p_do_apply,3}
Use pattern matching to assert that things work up to the call to thing:new/1:
ok = erlydb:start(mysql,Database),
ok = erlydb:code_gen(["thing.erl"],mysql),
You include only the stack trace, look at the exception message as well. I suspect that the error is that you get an 'undef' exception. But check that it is so. The first line in the stack trace indicates that it is a problem with calling thing:new/1 with ["name", "value"] as argument.
It is slightly odd that you show one clause of handle_request that is not calling home_controller:create/1 as per {home_controller,create,1} in the stack-trace. What do the other clauses in your handle_request/2 function look like?