最近在研究 aspect mock.
發現幾點要注意的:
- 文件有提到:
appDir defines the root of web application which is being tested. All classes outside the root will be replaced with the proxies generated by AspectMock. By default it is a directory in which vendor dir of composer if located. If you don’t use Composer or you have custom path to composer’s vendor’s folder, you should specify appDir.
意思是如果 你 include 要 mock 的 dir 不在 appDir 底下.
那就不行. - 如果你要 mock 的 class method 是繼承來的.
class 本身沒有去 override parent method.
那麼 parent class 也要在 include path 裡面. - 由於 asspect mock 是利用蓋掉已經註冊進去 spl autoload 的 composer ClassLoader
把它換成自己的, 所以像是 php 內建 Memcached 這種,
他就沒轍了…