小编620*_*030的帖子

PHPUnit - PHP 致命错误:在 null 上调用成员函数 GetOne()

我今天开始在 PhpStorm 上使用 PHPUnit 测试。我可以测试几乎所有的功能,除了需要数据库连接的功能。

功能:

public function getProductID()
{
     $this->product_id = $this->db->GetOne("select product_id from table1 where id = {$this->id}");
     return $this->product_id['product_id'];
}
Run Code Online (Sandbox Code Playgroud)

在我的测试用例中,出现错误:

PHP 致命错误:在 null 上调用成员函数 GetOne()

我已经定义:

global $_db;
$this->db = $_db;
Run Code Online (Sandbox Code Playgroud)

php phpunit unit-testing

2
推荐指数
1
解决办法
8573
查看次数

如何发送MarkDown到API

我正在尝试将一些 Markdown 文本发送到其余 api。刚才我发现 json 中不接受换行符。

\n\n

例子。如何将其发送到我的 api:

\n\n
An h1 header\n============\n\nParagraphs are separated by a blank line.\n\n2nd paragraph. *Italic*, **bold**, and `monospace`. Itemized lists\nlook like:\n\n  * this one\n  * that one\n  * the other one\n\nNote that --- not considering the asterisk --- the actual text\ncontent starts at 4-columns in.\n\n> Block quotes are\n> written like so.\n>\n> They can span multiple paragraphs,\n> if you like.\n\nUse 3 dashes for an em-dash. Use 2 dashes for ranges (ex., "it\'s all\nin chapters 12--14"). …
Run Code Online (Sandbox Code Playgroud)

rest markdown json

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

标签 统计

json ×1

markdown ×1

php ×1

phpunit ×1

rest ×1

unit-testing ×1