PHP5.3 模拟框架Prophecy.zip

时间:2022-08-05 10:40:26
【文件属性】:

文件名称:PHP5.3 模拟框架Prophecy.zip

文件大小:92KB

文件格式:NONE

更新时间:2022-08-05 10:40:26

开源项目

Prophecy 是功能强劲且灵活的 PHP 5.3 的模拟框架。尽管它最初是用来满足 phpspec2 的需求,但是它足够灵活,并且可以在任何测试框架中使用。示例代码:<?php class UserTest extends PHPUnit_Framework_TestCase {     private $prophet;     public function testPasswordHashing()     {         $hasher = $this->prophet->prophesize('App\Security\Hasher');         $user   = new App\Entity\User($hasher->reveal());         $hasher->generateHash($user, 'qwerty')->willReturn('hashed_pass');         $user->setPassword('qwerty');         $this->assertEquals('hashed_pass', $user->getPassword());     }     protected function setup()     {         $this->prophet = new \Prophecy\Prophet;     }     protected function tearDown()     {         $this->prophet->checkPredictions();     } } 标签:Prophecy  Web框架


网友评论