Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve documentation on mock: use of anonymous function to test arguments of a mocked method #302

Open
Grummfy opened this issue Aug 9, 2017 · 1 comment

Comments

@Grummfy
Copy link
Member

Grummfy commented Aug 9, 2017

We got feedback that we can improve the documentation on mock, and overall on the usage of assertion from anonymous function inside it.

see https://github.com/btry/flyve-mdm-glpi-plugin/blob/feature/atoum-ize_tests/tests/suite-integration/PluginFlyvemdmAgent.php#L399-412

      $mockedAgent->getMockController()->notify = function($topic, $mqttMessage, $qos = 0, $retain = 0)
                                                  use ($tester, &$mockedAgent) {
         $tester->string($topic)->isEqualTo($mockedAgent->getTopic() . "/Command/Unenroll");
         $tester->string($mqttMessage)->isEqualTo(json_encode(['unenroll' => 'now'], JSON_UNESCAPED_SLASHES));
         $tester->integer($qos)->isEqualTo(0);
         $tester->integer($retain)->isEqualTo(1);
      };
      $mockedAgent->update([
         'id'           => $mockedAgent->getID(),
         '_unenroll'    => '',
      ]);
      $this->mock($mockedAgent)->call('notify')->once();

see @btry to see if the documentation helps or not

@Grummfy
Copy link
Member Author

Grummfy commented Jan 3, 2018

wait until atoum/atoum#744 is merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant