public function testFunctions() { require_once __DIR__ . '/_fixture/SnapshotFunctions.php'; $snapshot = new Snapshot($this->getBlacklist(), false, false, false, true, false, false, false, false, false); $functions = $snapshot->functions(); $this->assertThat($functions, $this->logicalOr($this->contains('sebastianbergmann\\globalstate\\testfixture\\snapshotfunction'), $this->contains('SebastianBergmann\\GlobalState\\TestFixture\\snapshotFunction'))); $this->assertNotContains('assert', $functions); }
/** * Deletes function definitions that are not defined in a snapshot. * * @param Snapshot $snapshot * @throws RuntimeException when the uopz_delete() function is not available * @see https://github.com/krakjoe/uopz */ public function restoreFunctions(Snapshot $snapshot) { if (!function_exists('uopz_delete')) { throw new RuntimeException('The uopz_delete() function is required for this operation'); } $functions = get_defined_functions(); foreach (array_diff($functions['user'], $snapshot->functions()) as $function) { uopz_delete($function); } }