public function testPositiveTest()
 {
     $testCase = new SuccessfulStatusCode();
     $response = new MockUp();
     $response->setStatus(200);
     $testCase->test($response, Symfony::create(new Uri('http://www.example.com/')));
 }
Пример #2
0
 public function testGoodMaxSize()
 {
     $testCase = new Size();
     $testCase->init(null, 10);
     $response = new MockUp();
     $response->setBody('<body>');
     $testCase->test($response, Symfony::create(new Uri('http://www.example.com/')));
 }
Пример #3
0
 public function testTextNotFound()
 {
     $testCase = new TextNotPresent();
     $testCase->init('abc');
     $response = new MockUp();
     $response->setBody('bcdefg');
     $testCase->test($response, Symfony::create(new Uri('http://www.example.com/')));
 }
Пример #4
0
 public function testTextNotFound()
 {
     $testCase = new TextPresent();
     $testCase->init('abc');
     $response = new MockUp();
     $response->setBody('bcdefg');
     $this->setExpectedException('LiveTest\\TestCase\\Exception');
     $testCase->test($response, Symfony::create(new Uri('http://www.example.com/')));
 }
Пример #5
0
 public function testInvalidValidatorReponseRaisesException()
 {
     $testCase = new ValidMarkup();
     $testCase->init();
     $response = new MockUp();
     $response->setBody("no valid validator reponse at all");
     $this->setExpectedException('LiveTest\\TestCase\\Exception');
     $testCase->test($response, Symfony::create(new Uri('http://www.example.com/')));
 }
Пример #6
0
 public function testXPathInvalidXPath()
 {
     $testCase = new XPath();
     $testCase->init('\\bla', '/^titleBla$/');
     $response = new MockUp();
     $response->setBody('<html><head><title>titleBla</title></head></html>');
     $this->setExpectedException('LiveTest\\TestCase\\Exception');
     $testCase->test($response, Symfony::create(new Uri('http://www.example.com/')));
 }
Пример #7
0
 public function testPositiveTest()
 {
     $testCase = new HeaderExists();
     $testCase->init('Cache');
     $response = new MockUp();
     $response->setHeaders(array('No-Cache' => ''));
     $this->setExpectedException('LiveTest\\TestCase\\Exception');
     $testCase->test($response, Symfony::create(new Uri('http://www.example.com/')));
 }
Пример #8
0
 public function testCaseTest()
 {
     $stub = $this->getMockForAbstractClass('\\LiveTest\\TestCase\\General\\Html\\TestCase');
     $stub->expects($this->any())->method('runTest')->will($this->returnValue(TRUE));
     $response = new MockUp();
     $response->setBody('<html></html>');
     $request = Symfony::create(new Uri('http://www.example.com/'), 'get', array());
     $stub->test($response, $request);
     $this->assertEquals($request->getUri(), $stub->getRequest()->getUri());
 }
 public function testHandleResultLogStatuses()
 {
     $this->listener->init(__DIR__ . DIRECTORY_SEPARATOR . $this->logPath, array(Result::STATUS_SUCCESS));
     $test = new Test('', '');
     $response = new MockUp();
     $response->setStatus(200);
     $response->setBody('<body></body>');
     $result = new Result($test, Result::STATUS_FAILED, '', Request::create(new Uri('http://www.example.com')), new MockUp(), 'mySession');
     $this->listener->handleResult($result, $response);
     $this->assertFalse(file_exists($this->logPath . '/' . $this->createdFile));
 }
Пример #10
0
 public function testAnOtherRegExNotFound()
 {
     $testCase = new RegExNotPresent();
     $testCase->init('@^database.*error$@');
     $response = new MockUp();
     $response->setBody('database connection error');
     $this->setExpectedException('LiveTest\\TestCase\\Exception');
     $testCase->test($response, Symfony::create(new Uri('http://www.example.com/')));
     $response->setBody('database connection established');
     $testCase->test($response, Symfony::create(new Uri('http://www.example.com/')));
 }
Пример #11
0
 public function testHandleResult()
 {
     $test = new Test('', '');
     $response = new MockUp();
     $response->setStatus(200);
     ob_start();
     $result = new Result($test, Result::STATUS_SUCCESS, '', Request::create(new Uri('http://www.example.com')), $response, 'mySession');
     $this->listener->handleResult($result, $response);
     $result = new Result($test, Result::STATUS_FAILED, '', Request::create(new Uri('http://www.example.com')), $response, 'mySession');
     $this->listener->handleResult($result, $response);
     $result = new Result($test, Result::STATUS_ERROR, '', Request::create(new Uri('http://www.example.com')), $response, 'mySession');
     $this->listener->handleResult($result, $response);
     $output = ob_get_contents();
     ob_clean();
     $this->assertEquals('  Running: *fe', $output);
 }
Пример #12
0
 public function testOutput()
 {
     $listener = new StatusBar('', new Dispatcher());
     $test = new Test('', '');
     $response = new MockUp();
     $response->setStatus(200);
     $result = new Result($test, Result::STATUS_SUCCESS, '', Request::create(new Uri('http://www.example.com')), new MockUp(), 'mySession');
     $listener->handleResult($result, $response);
     $result = new Result($test, Result::STATUS_FAILED, '', Request::create(new Uri('http://www.example.com')), new MockUp(), 'mySession');
     $listener->handleResult($result, $response);
     $result = new Result($test, Result::STATUS_ERROR, '', Request::create(new Uri('http://www.example.com')), new MockUp(), 'mySession');
     $listener->handleResult($result, $response);
     ob_start();
     $listener->postRun(new Information('5000000', new Uri('http://www.example.com')));
     $actual = ob_get_contents();
     ob_clean();
     $expected = "  Tests: 3 (failed: 1, error: 1) - Duration: 1 hour(s) 23 minute(s) 20 second(s)";
     $this->assertEquals($expected, $actual);
 }