Skip to content

Commit f9ab94d

Browse files
committed
test full request with PHP
1 parent 602af56 commit f9ab94d

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

‎test/targets/php.js‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
'use strict';
2+
3+
var fixtures = require('../fixtures');
4+
var HTTPSnippet = require('../../src');
5+
var should = require('should');
6+
7+
describe('PHP', function () {
8+
it('should convert full request to cURL command', function (done) {
9+
var result = new HTTPSnippet(fixtures.full).php({
10+
indent: '\t'
11+
});
12+
13+
result.replace(/\n/g, '').should.eql('<?php$curl = curl_init();curl_setopt_array($curl, array(\tCURLOPT_URL => "http://httpconsole.com/debug?baz=abc&foo=bar&foo=baz",\tCURLOPT_RETURNTRANSFER => true,\tCURLOPT_ENCODING => "",\tCURLOPT_MAXREDIRS => 10,\tCURLOPT_TIMEOUT => 30,\tCURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,\tCURLOPT_CUSTOMREQUEST => "POST",\tCURLOPT_POSTFIELDS => "{\\"foo\\": \\"bar\\"}",\tCURLOPT_COOKIE => "foo=bar; bar=baz",\tCURLOPT_HTTPHEADER => array(\t\t"Accept: text/plain",\t\t"Content-Type: application/json",\t\t"X-Pretty-Print: 2"\t),));$response = curl_exec($curl);curl_close($curl);');
14+
15+
done();
16+
});
17+
});

0 commit comments

Comments
 (0)