我正在使用cuRL从远程服务器获取一些数据...响应是JSON格式..这是我的代码:
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER , 1);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)");
curl_setopt($ch, CURLOPT_URL, 'http://www.myaddress.com/mypage.php');
curl_setopt($ch, CURLOPT_POSTFIELDS, array("id" => $id));
$return = curl_exec($ch);
curl_close($ch);
Run Code Online (Sandbox Code Playgroud)
如果我在浏览器中访问链接页面加载OK,但如果我通过cuRL访问返回404错误...
在Laravel 5.1中,如果某些数据使用seeInDatabase($ table,$ fields)在数据库中,则有一种资产方法...
有没有办法断言某些数据是否不在数据库中?像dontSeeInDatabase这样的东西......与dontSeeJson类似
我需要使用Maintenance mode使用 artisan 命令"down",但仅适用于某些网址...
就我而言,我希望所有以开头的 url"/admin/*"继续工作。
有解决办法吗?
我正在Laravel 5.0中编写单元测试,在我的请求类中,我使用不同的包来显示验证错误消息.
我在我的文件中使用它:
/* ExampleRequest.php */
namespace App\Http\Requests;
use App\Http\Requests\Request;
use Illuminate\Support\Facades\Auth;
class ExampleRequest extends Request {
protected $errorBag = 'otherbag';
public function rules(){
return [
'my_field' => 'required'
];
}
}
Run Code Online (Sandbox Code Playgroud)
在我的测试文件中,我正在测试使用它:
/* ExampleTest.php */
class ExampleTest extends TestCase {
public function testPostWithoutData(){
$response = $this->call('POST', 'url/to/post',[
'my_field' => ''
]);
$this->assertSessionHasErrors('my_field');
}
}
Run Code Online (Sandbox Code Playgroud)
如果我运行测试,它无法获得正确的断言并返回此问题:
会议缺少错误:
my_field未能声称false是true.
如果我$errorBag从请求文件中取出属性,我没有问题.
我可以根据需要提供更多细节.
php unit-testing laravel-5 laravel-validation laravel-request
我有两个DIV,我认为我有一个保证金碰撞......
<div style="margin-bottom: 10px;">Example box</div>
<div style="margin-top: 10px;">Example box</div>
Run Code Online (Sandbox Code Playgroud)
我之间有10px,我想要20px ..有什么建议吗?
php ×4
laravel ×2
laravel-5 ×2
unit-testing ×2
css ×1
curl ×1
html ×1
http ×1
laravel-5.1 ×1
phpunit ×1