UNPKG

1.46 kBJavaScriptView Raw
1/***************************************************************************
2 *
3 * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved
4 * $Id$
5 *
6 **************************************************************************/
7
8
9
10/**
11 * php.spec.js ~ 2014/02/25 21:35:29
12 * @author leeight(liyubei@baidu.com)
13 * @version $Revision$
14 * @description
15 * 测试一下php handler
16 **/
17var path = require( 'path' );
18
19var base = require( './base' );
20var handler = require( '../lib/handlers/php' );
21
22var zit = function() {
23 return (process.env.USER === 'leeight' ? it : xit);
24}
25
26describe('php', function(){
27 zit()('default', function(){
28 var context = base.getContext();
29 context.request.pathname = '/hello.php';
30 context.request.url = '/hello.php?a=b';
31 context.request.headers = {
32 'host': 'www.baidu.com'
33 };
34
35 spyOn( context, 'start' ).andCallFake( function(){
36 runs(function(){
37 expect( context.start ).toHaveBeenCalled();
38 expect( context.start.callCount ).toBe( 1 );
39 expect( context.content.indexOf( '<title>phpinfo()</title>' ) ).not.toBe( -1 );
40 expect( context.content.indexOf( '</html>' ) ).not.toBe( -1 );
41 });
42 } );
43
44 handler()( context );
45
46 waitsFor(function(){ return context.start.callCount === 1 }, 'x', 1000)
47 });
48});
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72/* vim: set ts=4 sw=4 sts=4 tw=100: */