User:Jeroen De Dauw/Static: The S in STUPID/8

From semantic-mediawiki.org
Jump to: navigation, search
Jeroen De DauwJeroen De Dauw/Static: The S in STUPIDUser:Jeroen De Dauw/Static: The S in STUPID/8

The S in STUPID

Fixing the problem

public function doStuff( Logger $logger, DataStore $dataStore ) {
    // ...

    $logger->log( 'doing stuff during caturday is madness' );

    // ...

    $dataStore->saveObject( $object );

    // ...
}
  • Where Logger and DataStore are properly seggeragted interfaces
public function testDoStuff() {
    // ...

    // Create simple mocks
    $logger = new NullLogger();
    $dataStore = new MockDataStore();

    $object->doStuff( $logger, $dataStore );

    // ...
}