0

I'm checking out Codeception, and I'm trying to write my own grabber.

In my WebHelper.php:

function grabMaxOffers() 
{
    return 10;
}

(note: eventually, this will return a dynamic value)

In my TestCept.php file:

$max = $I->grabMaxOffers();
$I->wantToTest("Maximum offers ($max)");

There error I always get is:

PHP Notice: Object of class Codeception\Maybe could not be converted to int in tests/acceptance/TestCept.php on line 21

What am I missing? I wrote two other grabbers (returning strings) that worked fine.

Mike Crowe
  • 2,203
  • 3
  • 22
  • 37

1 Answers1

0
  1. You should not pass parameters into wantTo. wantTo is test name, nothing more. That's why test is failing.

  2. Codeception uses Maybe proxy object while analyzing the test. It mocks strings, array, or anything else. But it should be implicitly converted to string with (string)$max.

  3. Probably you wanted to use comments, and not wantTo statement. You should try amGoingTo method.

Cheers

Davert
  • 314
  • 1
  • 5