wikimedia/mediawiki-extensions-DonationInterface

View on GitHub
maintenance/TestCrash.php

Summary

Maintainability
A
0 mins
Test Coverage
#!/usr/bin/env php
<?php
// XXX only deployed for a quick debuggery party

$IP = getenv( 'MW_INSTALL_PATH' );
if ( $IP === false ) {
    $IP = __DIR__ . '/../../../..';
}

// If you get errors on this next line, set (and export) your MW_INSTALL_PATH var.
require_once "$IP/maintenance/Maintenance.php";

class TestCrash extends Maintenance {
    public function __construct() {
        parent::__construct();

        $this->requireExtension( 'Donation Interface' );

        $this->addOption( 'error', 'Yell ->error and exit' );
        $this->addOption( 'exception', 'Crash with an exception' );
        $this->addOption( 'fatal', 'Do something unexpected' );
    }

    public function execute() {
        if ( $this->getOption( 'error' ) ) {
            $this->fatalError( 'CRASHTEST: error' );
        }
        if ( $this->getOption( 'exception' ) ) {
            throw new RuntimeException( 'CRASHTEST: uncaught exception' );
        }
        if ( $this->getOption( 'fatal' ) ) {
            $this->error( 'CRASHTEST: fatal' );
            // @phan-suppress-next-line PhanUndeclaredClassMethod
            $everything_and_nothing = FOO::BAR();
        }

        $this->error( 'CRASHTEST: should not reach this line.' );
    }
}

$maintClass = TestCrash::class;
require_once RUN_MAINTENANCE_IF_MAIN;