草庐IT

lib_being_tested

全部标签

php - Laravel 5.2 测试 : Test is not running

我已经通过终端使用命令创建了一个测试:phpartisanmake:testUserTest现在我想使用以下命令运行测试:供应商/bin/UserTest但它返回bash:vendor/bin/UserTest:没有那个文件或目录PHPunit已安装。我检查过了。我错过了什么吗? 最佳答案 从Laravel根项目目录使用此命令运行测试:vendor/bin/phpunit如果你想运行自定义包测试,使用:vendor/bin/phpunitpackages/name/package/ 关于

php - 如何从 SELECT 查询中获取行数?给定的对象错误 : mysqli_affected_rows() expects parameter 1 to be mysqli,

我正在为表单进行服务器端验证。使用AJAX,表单将“用户名”输入字段中的值发送到我的PHP页面,然后检查该用户名是否已存在于数据库中。这是我的PHP代码:$result=mysqli_query($dblink,"SELECT*FROMusersWHERE`username`='$regname'")ordie(mysqli_error($dblink));echomysqli_affected_rows($result);*(目前我正在为mysqli_affected_rows做一个简单的回显,只是为了看看我的MySQL查询是否按预期工作)*我得到的错误是:Warning:mysql

php - C 中给出的警告 : fgetcsv() expects parameter 1 to be resource, bool 值:

我正在尝试使用fgetcsv()获取CSV,但出现如下错误:Warning:fgetcsv()expectsparameter1toberesource,booleangiveninC:..如果我var_dump($handle)确保输出是:Bool(False) 最佳答案 在尝试使用结果之前需要测试fopen是否成功:$handle=fopen($_FILES['filename']['tmp_name'],"r");if($handle){//Use$handle}else{die("Unabletoopenfile");}

php - 日期时间转换 : "The timezone could not be found in the database"

我正在尝试转换从API接收到的DateTime。这是他们生成日期时间字符串的方式:publicstaticfunctionformatDate($date){$format="Y-m-d\TH:i:sP";if($dateinstanceofDateTime){$d=$date->format($format);}elseif(is_numeric($date)){$d=date($format,$date);}else{$d=(String)"$date";}return$d;}这给了我"2013-06-14T04:00:36.000-03:00"这就是我将其转换回来的方法:try{

php - Symfony 2 Embedded Forms: Catchable Fatal Error: Argument 1 passed to Entity::addProperty must be an instance of XX\MyClass, 数组给定

我已经读过this和this和其他人,但没有人解决我的问题。我已经删除了所有可能的内容并将范围缩小到一个字段:地址。当我尝试关注thistutorial时,如果我遵循它,一切都会正常,从一个全新的新项目开始。但是当我在我的其他项目中手动执行时,我得到了这个错误:“可捕获的fatalerror:传递给BN\Bundle\MyBundle\Entity\PersonTeacher::addAdresse()的参数1必须是BN\Bundle\MyBundle\Entity\Adresse的实例,C:\Users\Olivier\PhpstormProjects\中给出的数组My\My\src

php - 如何避免 "Entities passed to the choice field must be managed. Maybe persist them in the entity manager?"

GeneratedEntities来自现有数据库GeneratedCRUDController但它不适用于异常消息:Entitiespassedtothechoicefieldmustbemanaged.Maybepersistthemintheentitymanager?实体/***Question**@ORM\Table(name="question",indexes={@ORM\Index(name="question_category_id",columns={"question_category_id"})})*@ORM\Entity*/classQuestion{//...

php -v 返回 dyld : Library not loaded:/usr/local/opt/readline/lib/libreadline. 7.dylib

我试图安装Valet,但由于错误,我从brew中卸载了php,现在我重新安装了php,如果我转到apache上的phpinfo()文件,我可以看到PHPVersion7.1.23但如果我在控制台上执行php-v或其他php命令,我会得到:dyld:Librarynotloaded:/usr/local/opt/readline/lib/libreadline.7.dylibReferencedfrom:/usr/local/bin/phpReason:imagenotfoundAborttrap:6我在MacOsSierra上 最佳答案

php - 在 Yii 中更改错误 'cannot be blank'

关于Yii中错误信息的处理:通常,Yii已经配置了表单的验证,当其中一个必填字段没有填写时,错误信息将显示为"Blablablacannotbeblank."如何自定义该错误消息?例如,我想改成这样:"Blablablatidakbolehkosong." 最佳答案 不清楚你到底想做什么,但是假设您想使用完全不同的消息:publicfunctionrules(){returnarray(array('title,content','required','message'=>'Pleaseenteravaluefor{attribut

PHP 可捕获 fatal error : Object of class could not be converted to string

我完全迷失在这里......在验证一些输入后,我创建了一个Message类的实例并尝试将数据插入数据库://sendmessage$message=$this->model->build('message',true);$message->insertMessage($uid,$user->user_id,$title,$message);插入的方法非常简单://insertanewmessagepublicfunctioninsertMessage($to_id,$from_id,$title,$body){$sql="INSERTINTOmessages(to_id,from_id

php - SQLSTATE[08001] : [Microsoft][ODBC Driver 13 for SQL Server]TCP Provider: No connection could be made because the target machine actively refused it

我的学说存储库代码无法运行,但我能够正常访问数据库和读取表数据。我得到这个堆栈跟踪:EntityManager->getRepository('AppBundle:Person')insrc\AppBundle\Controller\PersonViewController.php(line18)publicfunctionindexAction(Request$request){$em=$this->getDoctrine()->getManager();$repo=$em->getRepository('AppBundle:Person');$persons=$repo->find