Skip to content

@eddiejaoude /Q3.php
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
PHP Test
<?php
/*
* Q. (20-30mins)
* Architect skeleton classes/methods & unit tests for a logging system
* with multiple input structures & output formats. Use the following
* design concepts: interface, factory, adapter, custom exception, type
* hinting.
*
* @author Eddie Jaoude
* @package Test
*/
// A.
// File: Logger.php
class Logger {
public static function factory($name, Logger_Adapter_Interface
$adapter) {}
}
// File: Tests/LoggerTest.php
class Test_LoggerTest {
public function testFactoryWithCorrectNameAndCorrectAdapter() {}
public function testFactoryWithIncorrectNameAndCorrectAdapter() {}
public function testFactoryWithCorrectNameAndIncorrectAdapter() {}
public function testFactoryWithIncorrectNameAndIncorrectAdapter() {}
}
// File: Logger/Adapter/Interface.php
interface Logger_Adapter_Interface {
public function getMessage();
public function getDateTime();
}
// File: Logger/Adapter/Standard.php
class Logger_Adapter_Standard implements Logger_Adapter_Interface {
public function setMessage() {}
public function getMessage() {}
public function setDateTime() {}
public function getDateTime() {}
}
// File: Tests/Logger/Adapter/Standard.php
class Test_Logger_Adapter_StandardTest {
public function testSetMessagewithValue() {}
public function testSetMessagewithNoValue() {}
public function testGetMessage() {}
public function testSetDateTimeWithDateTime() {}
public function testSetDateTimeWithInvalidDateTime() {}
public function testSetDateTimeWithNoDateTime() {}
public function testGetDateTime() {}
}
// File: Logger/Adapter/Exception.php
class Logger_Adapter_Exception extends Logger_Exception {}
// File: Tests/Logger/Adapter/Exception.php
class Test_Logger_Adapter_ExceptionTest {
public function testException() {}
}
// File: Logger/Factory/Interface.php
interface Logger_Factory_Interface {
public function save();
}
// File: Logger/Factory/File.php
class Logger_Factory_File implements Logger_Factory_Interface {
public method save() {}
}
// File: Tests/Logger/Factory/File.php
class Test_Logger_Factory_FileTest {
public method testSaveCreateFile() {}
public method testSaveAppendFile() {}
}
// File: Logger/Factory/Exception.php
class Logger_Factory_Exception extends Logger_Exception {}
// File: Tests/Logger/Factory/Exception.php
class Test_Logger_Factory_ExceptionTest {
public function testException() {}
}
// File: Logger/Exception.php
class Logger_Exception extends Exception {}
// File: Tests/Logger/Exception.php
class Test_Logger_ExceptionTest {
public function testException() {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.