atoum / atoum-documentation

Documentation of atoum, a php unit test framework
http://docs.atoum.org
Other
10 stars 41 forks source link

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

Open Grummfy opened 7 years ago

Grummfy commented 7 years ago

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 commented 6 years ago

wait until https://github.com/atoum/atoum/pull/744 is merged