Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

# Mark external tests as skipped when the network is not available.

  • Loading branch information...
commit e677d6eab354757f7086295c57a2f206834a88bc 1 parent 4b09542
@manuelpichler manuelpichler authored
View
20 tests/Tasks/CheckoutTaskTest.php
@@ -69,6 +69,16 @@ class phpucCheckoutTaskTest extends phpucAbstractTaskTest
*/
protected function setUp()
{
+ $socket = @fsockopen( 'xplib.de', 80, $errno, $errstr, 1);
+ if ( is_resource( $socket ) )
+ {
+ fclose( $socket );
+ }
+ else
+ {
+ $this->markTestSkipped( 'Cannot connect to pserver.' );
+ }
+
$this->cwd = getcwd();
parent::setUp();
@@ -118,16 +128,6 @@ public function testSubversionCheckout()
*/
public function testCvsCheckout()
{
- $socket = @fsockopen( 'xplib.de', 2401, $errno, $errstr, 1);
- if ( is_resource( $socket ) )
- {
- fclose( $socket );
- }
- else
- {
- $this->markTestSkipped( 'Cannot connect to pserver.' );
- }
-
$this->prepareArgv(
array(
'project',
View
30 tests/VersionControl/AbstractCheckoutTest.php
@@ -65,16 +65,12 @@
* property.
*
* @return void
+ * @expectedException OutOfRangeException
*/
public function testGetterUnknownPropertyFail()
{
- $this->setExpectedException(
- 'OutOfRangeException',
- 'Unknown or writonly property $phpuc.'
- );
-
$checkout = $this->createCheckout();
- echo $checkout->phpuc;
+ $property = $checkout->phpuc;
}
/**
@@ -93,6 +89,28 @@ public function testSetterUnknownPropertyFail()
$checkout = $this->createCheckout();
$checkout->phpuc = true;
}
+
+ /**
+ * Marks a test case as skipped when the remote host is not available.
+ *
+ * @param string $remote The remote host name + port.
+ *
+ * @return void
+ */
+ protected function markTestSkippedWhenRemoteHostNotAvailable( $remote )
+ {
+ $url = parse_url( $remote );
+
+ $socket = @fsockopen( $url['host'], $url['port'], $errno, $errstr, 1);
+ if ( is_resource( $socket ) )
+ {
+ fclose( $socket );
+ }
+ else
+ {
+ $this->markTestSkipped( 'Cannot connect to host ' . $remote . '.' );
+ }
+ }
/**
* Test factory method.
View
10 tests/VersionControl/CvsCheckoutTest.php
@@ -104,15 +104,7 @@ protected function tearDown()
*/
public function testPServerCheckout()
{
- $socket = @fsockopen( 'xplib.de', 2401, $errno, $errstr, 1);
- if ( is_resource( $socket ) )
- {
- fclose( $socket );
- }
- else
- {
- $this->markTestSkipped( 'Cannot connect to pserver.' );
- }
+ $this->markTestSkippedWhenRemoteHostNotAvailable( 'xplib.de:2401' );
$destination = PHPUC_TEST_DIR . '/source';
$checkFile1 = $destination . '/pdepend.php';
View
2  tests/VersionControl/GitCheckoutTest.php
@@ -104,6 +104,8 @@ protected function tearDown()
*/
public function testGitCheckoutNoLogin()
{
+ $this->markTestSkippedWhenRemoteHostNotAvailable( 'github.com:80' );
+
$checkFile = PHPUC_TEST_DIR . '/source/src/PhpUnderControl.php';
$this->assertFileNotExists( $checkFile );
View
11 tests/VersionControl/SubversionCheckoutTest.php
@@ -77,11 +77,6 @@ protected function setUp()
{
parent::setUp();
- if ( @file_get_contents( 'http://phpundercontrol.org' ) === false )
- {
- $this->markTestSkipped( 'Cannot connect to external host.' );
- }
-
phpucFileUtil::setOS();
phpucFileUtil::setPaths();
@@ -109,6 +104,8 @@ protected function tearDown()
*/
public function testSvnCheckoutNoLogin()
{
+ $this->markTestSkippedWhenRemoteHostNotAvailable( 'xplib.de:80' );
+
$destination = PHPUC_TEST_DIR . '/source';
$checkFile1 = $destination . '/pdepend.php';
$checkFile2 = $destination . '/PHP/Depend.php';
@@ -146,6 +143,8 @@ public function testSvnCheckoutInvalidUrlFail()
*/
public function testSvnCheckoutWithLogin()
{
+ $this->markTestSkippedWhenRemoteHostNotAvailable( 'xplib.de:80' );
+
$destination = PHPUC_TEST_DIR . '/source';
$checkFile1 = $destination . '/Commands/AbstractCommand.php';
$checkFile2 = $destination . '/Commands/InstallCommand.php';
@@ -203,6 +202,8 @@ public function testSvnCheckoutWithInvalidPasswordFail()
*/
public function testHttpCheckout()
{
+ $this->markTestSkippedWhenRemoteHostNotAvailable( 'xplib.de:80' );
+
$destination = PHPUC_TEST_DIR . '/source';
$checkFile1 = $destination . '/pdepend.php';
$checkFile2 = $destination . '/PHP/Depend.php';
Please sign in to comment.
Something went wrong with that request. Please try again.