小编onu*_*rli的帖子

在命令行上运行 yii 控制器/操作

是否可以像使用 CodeIgniter 一样在 linux 命令行上运行 yii 控制器/动作?

CI 风格:php index.php 控制器操作

command-line yii

6
推荐指数
1
解决办法
7680
查看次数

Yii功能测试不适用于phpunit

Phpunit在基本项目中正常工作,但是当我尝试在yii功能测试中使用时,我收到此错误: PHP致命错误:在〜/ phpunit/vendor/phpunit/phpunit-selenium中调用未定义的方法PHPUnit_Framework_Warning :: setupSpecificBrowser()第95行的/PHPUnit/Extensions/SeleniumBrowserSuite.php

我用composer安装了phpunit.版本:Sebastian Bergmann的PHPUnit 4.0.17.Selenium版本:2.41.0

我像这样运行selenium:java -jar selenium-server-standalone-2.41.0.jar

我像这样运行测试类:〜/ phpunit/vendor/bin/phpunit functional/SiteTest.php

在基本项目代码中:

class WebTest extends PHPUnit_Extensions_Selenium2TestCase
{
    protected function setUp()
    {
        $this->setBrowser('firefox');
        $this->setBrowserUrl('http://www.example.com/');
    }

    public function testTitle()
    {
        $this->url('http://www.example.com/');
        $this->assertEquals('Title string', $this->title());
    }

}
Run Code Online (Sandbox Code Playgroud)

Yii代码:

class WebTestCase extends CWebTestCase
{
    protected function setUp()
    {
        parent::setUp();
        $this->setBrowserUrl(Yii::app()->params['url']['base']);
    }
}
Run Code Online (Sandbox Code Playgroud)

此外,CWebTestCase类还存在PHPUnit_Extensions_SeleniumTestCase类,而不是PHPUnit_Extensions_Selenium2TestCase.

php selenium phpunit yii

5
推荐指数
1
解决办法
591
查看次数

使用Python将图像转换为十六进制格式

我的文件夹下有一个jpg文件tmp

upload_path = /tmp/resized-test.jpg
Run Code Online (Sandbox Code Playgroud)

我一直在使用下面的代码:

方法一

with open(upload_path, "rb") as image_file:
    encoded_string = base64.b64encode(image_file.read())
Run Code Online (Sandbox Code Playgroud)

方法2

def imgToHex(file):
    string = ''
    with open(file, 'rb') as f:
        binValue = f.read(1)
        while len(binValue) != 0:
            hexVal = hex(ord(binValue))
            string += '\\' + hexVal
            binValue = f.read(1)
    string = re.sub('0x', 'x', string) # Replace '0x' with 'x' for your needs
    return string
imgToHex(upload_path)
Run Code Online (Sandbox Code Playgroud)

但他们都没有按照我想要的方式工作。

python hex image

3
推荐指数
1
解决办法
1万
查看次数

标签 统计

yii ×2

command-line ×1

hex ×1

image ×1

php ×1

phpunit ×1

python ×1

selenium ×1