doupang1917 2017-06-05 12:58
浏览 19
已采纳

PHPUnit找不到Phalcon的Callback验证器(命名空间问题)

I'm using Phalcon 3.0.3 and PHP 7.0.15-0ubuntu0.16.04.4 with PHPUnit 6.0.8. If I try to use Phalcon\Validation\Validator\Callback I'll always end up with those kind of errros:

1) Test\ConfirmActivityTest::testConfirm Error: Class 'Phalcon\Validation\Validator\Callback' not found

So far the only way I found to solve this problem is to create a copy of that class in my codebase:

namespace Phapp\Validators;

/**
 * A workaround to fix the namespace problem of
 * Phalcon\Validation\Validator\Callback
 *
 */
class CallbackValidator extends \Phalcon\Validation\Validator
{

    /**
     * Executes the validation
     *
     * @param \Phalcon\Validation $validation
     * @param string $field
     * @return bool
     */
    public function validate(\Phalcon\Validation $validation, $field) {}

}

Is there any other workaround I could use to solve this problem? Is it a Phalcon bug?

  • 写回答

1条回答 默认 最新

  • doutongya8378 2017-06-05 19:50
    关注

    Callback validator was added in 3.1.0. Docs were by mistake merged as i remember.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 PADS Logic 原理图
  • ¥15 PADS Logic 图标
  • ¥15 电脑和power bi环境都是英文如何将日期层次结构转换成英文
  • ¥20 气象站点数据求取中~
  • ¥15 如何获取APP内弹出的网址链接
  • ¥15 wifi 图标不见了 不知道怎么办 上不了网 变成小地球了