Static method

How can I test code that calls a public static method from an external class?

src/Database.php
<?php namespace Example; use PDO; class Database { public function getDrivers() { PDO::getAvailableDrivers(); } }

Add it to your list of side effects:

lens/tests/Database.php
<?php namespace Example; use PDO; // Test $database = new Database(); $drivers = $database->getDrivers(); // Effect PDO::getAvailableDrivers(); // return []; // Effect PDO::getAvailableDrivers(); // return ['mysql']; // Effect PDO::getAvailableDrivers(); // return ['mysql', 'sqlite'];

Download this example