phpunit

Laravel Phpunit Test

三世轮回 提交于 2020-02-18 05:27:45
Create php test unit case php artisan make:test GetPosTest —unit vim tests/Unit/GetPosTest.php <?php namespace Tests \ Unit ; use App \ Services ; use Tests \ TestCase ; use Illuminate \ Foundation \ Testing \ WithFaker ; use Illuminate \ Foundation \ Testing \ RefreshDatabase ; class GetPosTest extends TestCase { private static $empty_array = [ ] ; private static $one_item_array = [ [ 'posx' = > 327 , 'poxy' = > 444 ] ] ; private static $more_items_array_1 = [ [ 'posx' = > 82 , 'poxy' = > 444 ] , [ 'posx' = > 327 , 'poxy' = > 444 ] , [ 'posx' = > 230 , 'poxy' = > 622 ] , ] ; private static

安装 phpUnit

醉酒当歌 提交于 2020-02-16 19:07:26
如果没有安装pear先安装pear http://pear.php.net/go-pear.phar 下载文件go-pear.phar到php安装目录下 命令行执行:php go-pear.phar 添加channel: pear channel-discover pear.phpunit.de pear channel-discover components.ez.no pear channel-discover pear.symfony-project.com 然后安装PHPUnit: pear install phpunit/PHPUnit 如果安装失败 那么我们更新一下pear就可以了: pear channel-update pear.php.net pear upgrade-all 再安装: pear install phpunit/PHPUnit 来安装PHPUnit,应该就可以看到Install ok了。 如果还是不行,执行下 pear clear-cache 再安装 Error: Unknown remote channel : pear . symfony . com phpunit / PHPUnit requires package "channel://pear.symfony.com/Yaml" ( version >= 2.1 . 0 ) No

php的单元测试,PHPUnit安装

杀马特。学长 韩版系。学妹 提交于 2020-02-15 07:48:25
最近研究php的单元测试功能,在centos下和widows下安装了phpunit 首先要保证 你装的php中安装了pear linux下输入命令pear 回车可看一下是否安装了 windows下可以用dos进入到php的安装目录 ,输入命令pear 回车可看一下是否安装了 在默认情况下php中都会安装的 pear的安装 windows下用dos进入php的安装根目录 运行go-pear,r然后输入两次yes 然后 后边的选项直接用回车 然后我们要添加Channel pear channel-discover pear.phpunit.de pear channel-discover components.ez.no pear channel-discover pear.symfony-project.com 我在这个地方遇到了 .lock 访问权限的错误而安装失败,这是我们可以在PEAR文件夹下删除此文件 开始安装phpunit,首先升级pear,输入命令 pear upgrade pear 接下来执行pear install --alldeps --force phpunit/PHPUnit,此时我遇到了下图所示的问题,包依赖 很简单 我们把这些包用pear install命令安装了 即可 可能执行完这个之后你的phpunit还是提示安装失败 它提示我们要更新pear包

windows下安装PEAR, PHPUnit

心不动则不痛 提交于 2020-02-14 17:44:40
1、 Windows 的开始 -> 运行 ->cmd 2、安装命令 进入php所在目录,执行命令:go-pear.bat Are you installing a system-wide PEAR or a local copy? (system|local) [system] : 敲击回车键 (Enter) Below is a suggested file layout for your new PEAR installation. To change individual locations, type the number in front of the directory. Type ‘all’ to change all of them or simply press Enter to accept these locations. 1. Installation base ($prefix) : D:\APMServ5.2.6\PHP 2. Temporary directory for processing : D:\APMServ5.2.6\PHP\tmp 3. Temporary directory for downloads : D:\APMServ5.2.6\PHP\tmp 4. Binaries directory : D:\APMServ5.2.6

Installing PEAR and PHPUnit on WAMP

丶灬走出姿态 提交于 2020-02-14 03:23:29
1.安装wamp 2.安装PEAR Step: 打开 C:\wamp\bin\php\php5.3.5\php.ini 修改: ;phar.require_hash = On phar.require_hash = Off 运行C:\wamp\bin\php\php5.3.5\ go-pear.bat 选择local,默认 YES 添加环境变量: variable ‘PHP_PEAR_PHP_BIN’ 为C:\wamp\bin\php\php5.3.5\php.exe 修改path,添加: C:\wamp\bin\php\php5.3.5\ 重启apache 3安装PHPUnit 先下载 Structures_Graph http://pear.php.net/package/Structures_Graph/download/ 解压 Structures 放在C:\wamp\bin\php\php5.3.5\PEAR 然后运行: pear install Structures_Graph-1.0.4 pear upgrade pear pear channel-discover components.ez.no pear channel-discover pear.phpunit.de pear channel-discover pear.symfony-project.com

phpstorm使用phpunit的方法

半腔热情 提交于 2020-02-08 01:42:46
1、首先下载phpunit composer require --dev phpunit/phpunit ^7 这个CLI很重要,要不然后续的配置不行,我这边是配置了PHP的全局变量,就是php.exe的位置。 3、配置 出现phpunit的版本version说明可以了 4.配置需要测试的范围 这样配置完就可以run了 然后是如何生成测试文件 单击要测试的类 选择生成的位置等等 然后引入文件后,就可以右上角点了 单一的方法可以点左侧就行了 来源: CSDN 作者: PHP加油 链接: https://blog.csdn.net/qq_36085872/article/details/104212351

Mocking Laravel custom validation rule class not working

こ雲淡風輕ζ 提交于 2020-02-06 07:56:52
问题 I'm implementing a new custom validation rule in form submit. But I want to bypass the validation rule in unit testing. Below is the simplified of the validation rule and unit test class. What am I missing? namespace App\Rules; use Illuminate\Contracts\Validation\Rule; class Captcha implements Rule { public function passes($attribute, $value) { // assuming will always return false in testing // works fine when true return false; } public function message() { return 'Captcha error! Try again

Mocking Laravel custom validation rule class not working

依然范特西╮ 提交于 2020-02-06 07:56:19
问题 I'm implementing a new custom validation rule in form submit. But I want to bypass the validation rule in unit testing. Below is the simplified of the validation rule and unit test class. What am I missing? namespace App\Rules; use Illuminate\Contracts\Validation\Rule; class Captcha implements Rule { public function passes($attribute, $value) { // assuming will always return false in testing // works fine when true return false; } public function message() { return 'Captcha error! Try again

Invalid response while accessing the Selenium Server

旧街凉风 提交于 2020-02-04 08:12:31
问题 I tested PHPUnit with the Selenium Server but I can't test something like login button. If I write for my login element css=input.login like that $this->click("css=input.login"); but I see the following errors Invalid response while accessing the Selenium Server and `Value does not implement interface Event. 回答1: This turns out to be a Selenium Server bug, solved in the latest version. But this bug still can be encountered in the Netbeans Selenium Server plugin which is using an older version

How to test for static files located in the web folder in symfony with phpunit?

你离开我真会死。 提交于 2020-02-03 05:38:26
问题 sysinfo: PHPUnit 5.7.4 PHP 7.0.13 Symfony 3.2.1 i am trying to follow a link on a "download" page and verify the file is downloadable but when i follow the link $client->click($crawlerDownload->link()); i get a 404 . is it not possible for the symfony $client to access a static file in the webdirectory? how can i test this? the favicon test is the simplified version of the testcase. public function testPressDownload() { $client = static::createClient(); $client->followRedirects(false); /