-
-
Save ahmed-abid/ca11da1c836518e1f898de400b06f30d to your computer and use it in GitHub Desktop.
PHP code is now 99% testable with AspectMock
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\AspectMock; | |
class ActiveRecord | |
{ | |
public function save($name) | |
{ | |
return 'saved ActiveRecord success' . $name; | |
} | |
} | |
class UserModel | |
{ | |
public static function tableName() | |
{ | |
return 'users'; | |
} | |
public static function someMethod($arg1, $arg2) | |
{ | |
return $arg1 . ' '. $arg2; | |
} | |
} | |
class NoDependencyInjectionNeeded | |
{ | |
public function getName() | |
{ | |
$user = new UserModel(); | |
$name = $user->tableName(); | |
return $name . ' — No Dependency Injection Needed'; | |
} | |
} | |
class User2 extends ActiveRecord | |
{ | |
public $name = 'user2 name'; | |
public function __construct($name) | |
{ | |
$this->name = $name; | |
} | |
public function getTime() | |
{ | |
return time(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment