3 include_once __DIR__ . '/parse_args.php';
5 class DemoFilesTest extends PHPUnit_Framework_TestCase
7 public $args = array();
12 /** @var boolean $collectCodeCoverageInformation */
13 protected $collectCodeCoverageInformation;
14 protected $coverageScriptUrl;
16 public function run(PHPUnit_Framework_TestResult $result = NULL)
18 $this->testId = get_class($this) . '__' . $this->getName();
20 if ($result === NULL) {
21 $result = $this->createResult();
24 $this->collectCodeCoverageInformation = $result->getCollectCodeCoverageInformation();
28 if ($this->collectCodeCoverageInformation) {
29 $coverage = new PHPUnit_Extensions_SeleniumCommon_RemoteCoverage(
30 $this->coverageScriptUrl,
33 $result->getCodeCoverage()->append(
34 $coverage->get(), $this
38 // do not call this before to give the time to the Listeners to run
39 //$this->getStrategy()->endOfTest($this->session);
44 public function setUp()
46 $this->args = argParser::getArgs();
48 $this->baseUrl = $this->args['LOCALSERVER'] . str_replace( '/demo/server/server.php', '/demo/', $this->args['URI'] );
50 $this->coverageScriptUrl = 'http://' . $this->args['LOCALSERVER'] . '/' . str_replace( '/demo/server/server.php', 'tests/phpunit_coverage.php', $this->args['URI'] );
53 protected function request($file, $method = 'GET', $payload = '')
55 $url = $this->baseUrl . $file;
57 $ch = curl_init($url);
58 curl_setopt_array($ch, array(
59 CURLOPT_RETURNTRANSFER => true,
60 CURLOPT_FAILONERROR => true
62 if ($method == 'POST')
64 curl_setopt_array($ch, array(
66 CURLOPT_POSTFIELDS => $payload
69 if ($this->collectCodeCoverageInformation)
71 curl_setopt($ch, CURLOPT_COOKIE, 'PHPUNIT_SELENIUM_TEST_ID=true');
73 if ($this->args['DEBUG'] > 0) {
74 curl_setopt($ch, CURLOPT_VERBOSE, 1);
76 $page = curl_exec($ch);
79 $this->assertNotFalse($page);
80 $this->assertNotContains('Fatal error', $page);
81 $this->assertNotContains('Notice:', $page);
86 public function testAgeSort()
88 $page = $this->request('client/agesort.php');
91 public function testClient()
93 $page = $this->request('client/client.php');
95 // we could test many more calls to the client demo, but the upstream server is gone anyway...
97 $page = $this->request('client/client.php', 'POST', array('stateno' => '1'));
100 public function testComment()
102 $page = $this->request('client/comment.php');
103 $page = $this->request('client/client.php', 'POST', array('storyid' => '1'));
106 public function testIntrospect()
108 $page = $this->request('client/introspect.php');
111 public function testMail()
113 $page = $this->request('client/mail.php');
114 $page = $this->request('client/client.php', 'POST', array(
125 public function testSimpleCall()
127 $page = $this->request('client/simple_call.php');
130 public function testWhich()
132 $page = $this->request('client/which.php');
135 public function testWrap()
137 $page = $this->request('client/wrap.php');
140 public function testZopeTest()
142 $page = $this->request('client/zopetest.php');
145 public function testDiscussServer()
147 $page = $this->request('server/discuss.php');
148 $this->assertContains('<name>faultCode</name>', $page);
149 $this->assertContains('<int>105</int>', $page);
152 public function testProxyServer()
154 $page = $this->request('server/proxy.php');
155 $this->assertContains('<name>faultCode</name>', $page);
156 $this->assertContains('<int>105</int>', $page);