append(new Result(['foo' => 'bar'])); // Create a "ListObjects" command $command = $s3Client->getCommand('ListObjects'); // Associate the mock handler with the command $command->getHandlerList()->setHandler($mock); // Executing the command will use the mock handler, which will return the // mocked result object $result = $client->execute($command); echo $result['foo']; // Outputs 'bar' // snippet-end:[s3.php.mock_handler.main] // snippet-end:[s3.php.mock_handler.complete] // snippet-sourceauthor:[jschwarzwalder (AWS)]