public
Created

PHP Test

  • Download Gist
Q3.php
PHP
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
<?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() {}
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.