Call to undefined method AcceptanceTester::getModule - codeception

Here is my code -
<?php
class ClassiDescCest{
public function desc(AcceptanceTester $I){
$classifications = $this->getModule('WebDriver')->_findElements('/html/body/div[1]/div/section/div/div/div/div/div[2]/div[2]/div[1]/div/div/span/a/span');
echo $classifications.size();
}
}
Here is the error that I am getting -
Error for undefined method

$this->getModule() can't be used in the Cest file,
_findElements is a hidden method and can only be used in helpers as documented in http://codeception.com/docs/06-ModulesAndHelpers
Also check if grabMultiple method does what you need.

Related

How to write custom errors and return messages with error keyword Solidity

I tried to make a custom error but it doesn't return a message to revert
How could I make it return a message?
/// custom error
error MyCustomError(address _address);
if user { revert MyCustomError({address: msg.sender}) }
I got this error
Runtime error: revert
There are two errors:
1- if statement should be inside a function
2- when you defined the custom error,you defined the named parameter as _address
contract Test {
address public user;
/// custom error
error MyCustomError(address _address);
function revertError() public view {
// I just had to pass a valid condition. address(0)=0x0000000000000000000000000000000000000000
// if(user) would give this error: "Type address is not implicitly convertible to expected type bool"
if(user!=address(0))
{
revert MyCustomError({_address: msg.sender});
}
}
}

sharedObject does not save my data.

static private function ifonEnternameFrame():Void
{
so.data.name = _root.getName.text;
//trace(so.data.name);
_root.nameBtn.onPress = function ()
{
_root.gotoAndStop(2);
}
}
When you start the application this code will save your name.
But when you then go to another function then it says that it's undefined.
trace(so.data.name);
I traced this when I was on the next frame and it couldn't find the previous name.
Please help.
Flushing the shared object data is necessary to get those variables.
Use the flush function of shared object.
Your problem doesn't come from SharedObject. The origin of your error message is that your textField getName is incorrectly named in your code.
If you trace _root.getName.text in your function ifonEnternameFrame you shall have the same error message:
trace(_root.getName.text); // undefined

build a new function as afterSave() Yii

I am building a shoping cart in Yii. Now I want to buid a function with name is afterCharged() the same as afterSave(). So how to can do it? Thank you in advance
As Michiel said you should use an event in your method
function charge(){
//Perform charge related actions
$this->onCharge(new CEvent($this));
//... maybe some code over here after raising the event
}
public function onCharge($event){
$this->raiseEvent('onCharge', $event);
}
Now you have to catch the raised event. So in this component you'll declare which class and which mehod need to catch it (for example in the init method)
//OtherClass need to catch the the charge event
$callback = array(new OtherClass,'afterCharge')
$component->onCharge = $callback;
So the method afterCharge of OtherClass will be called when charge() is executed.
By the way, the method afterCharge must have the following signature
function afterCharge($event) {
}
Sources:
The wiki
Yii docs

codeception assertTrue() equivalent?

I've gone through the documentation several times, and through the source, and it doesn't work.
I'm looking for the Codeception equivalent of PHPUnit's "this->assertTrue($var)".
According to the documentation, just like that is should work, but it doesn't, "undefined method". Which helper, module or whatever do I have to activate?
Did you enabled the module 'asserts' in the corresponding suite.yml file? Like:
class_name: UnitTester
modules:
enabled: [Asserts, UnitHelper]
Here is what I wrote in the tests/_helpers/WebHelper.php
(note: WebHelper must be enabled in the .yml)
class WebHelper extends \Codeception\Module {
/**
* #param bool $a
*/
function seeTrue( $a ) {
$this->assertTrue( $a );
}
}
Then, I ran
php codecept.phar build
And now I can write
$I->seeTrue(true);
You just call
\PHPUnit_Framework_Assert::assertTrue (...);

vtable error. "vtable for ETRun", referenced from:

I have an object called Run. I can instantiate in header of a class. But, when i try to do the same .cpp file the above error was popped out.
vtable error. "vtable for Run",
referenced from:
__ZTV5Run$non_lazy_ptr in Para.o
string Para::name()
{
Run* newRun = new Run;
return mName;
}
how can i get out of this error...
This probably happens because Run is a derived class, and it has a declaration of some virtual function but this function is not implemented.
Try to check whether your problem is this case.