From 8eb7f3a798b6dc01214c836749484d5c3d04bc74 Mon Sep 17 00:00:00 2001 From: Gabriel Caruso Date: Thu, 7 Dec 2017 18:08:19 -0200 Subject: [PATCH] Refactoring tests --- tests/Functional/Net/SCPSSH2UserStoryTest.php | 5 +++-- tests/Functional/Net/SFTPStreamTest.php | 4 ++-- tests/Functional/Net/SFTPUserStoryTest.php | 5 +++-- tests/Functional/Net/SSH2Test.php | 5 +++-- tests/Unit/File/ANSITest.php | 4 ++-- 5 files changed, 13 insertions(+), 10 deletions(-) diff --git a/tests/Functional/Net/SCPSSH2UserStoryTest.php b/tests/Functional/Net/SCPSSH2UserStoryTest.php index 05e85103..fe4852a8 100644 --- a/tests/Functional/Net/SCPSSH2UserStoryTest.php +++ b/tests/Functional/Net/SCPSSH2UserStoryTest.php @@ -42,8 +42,9 @@ class Functional_Net_SCPSSH2UserStoryTest extends PhpseclibFunctionalTestCase public function testConstructor($ssh) { $scp = new SCP($ssh); - $this->assertTrue( - is_object($scp), + $this->assertInternalType( + 'object', + $scp, 'Could not construct \phpseclib\Net\SCP object.' ); return $scp; diff --git a/tests/Functional/Net/SFTPStreamTest.php b/tests/Functional/Net/SFTPStreamTest.php index 9507aca3..3a0cfabf 100644 --- a/tests/Functional/Net/SFTPStreamTest.php +++ b/tests/Functional/Net/SFTPStreamTest.php @@ -22,7 +22,7 @@ class Functional_Net_SFTPStreamTest extends Functional_Net_SFTPTestCase 'sftp' => ['session' => $this->sftp], ]); $fp = fopen($this->buildUrl('fooo.txt'), 'wb', false, $context); - $this->assertTrue(is_resource($fp)); + $this->assertInternalType('resource', $fp); fclose($fp); $this->assertSame(0, $this->sftp->size('fooo.txt')); } @@ -39,7 +39,7 @@ class Functional_Net_SFTPStreamTest extends Functional_Net_SFTPTestCase fputs($fp, 'zzzz'); fclose($fp); - $this->assertTrue(in_array('te#st.txt', $this->sftp->nlist())); + $this->assertContains('te#st.txt', $this->sftp->nlist()); } /** diff --git a/tests/Functional/Net/SFTPUserStoryTest.php b/tests/Functional/Net/SFTPUserStoryTest.php index b66e3496..09503539 100644 --- a/tests/Functional/Net/SFTPUserStoryTest.php +++ b/tests/Functional/Net/SFTPUserStoryTest.php @@ -29,8 +29,9 @@ class Functional_Net_SFTPUserStoryTest extends PhpseclibFunctionalTestCase { $sftp = new SFTP($this->getEnv('SSH_HOSTNAME')); - $this->assertTrue( - is_object($sftp), + $this->assertInternalType( + 'object', + $sftp, 'Could not construct NET_SFTP object.' ); diff --git a/tests/Functional/Net/SSH2Test.php b/tests/Functional/Net/SSH2Test.php index f6be7d25..b2fe5d80 100644 --- a/tests/Functional/Net/SSH2Test.php +++ b/tests/Functional/Net/SSH2Test.php @@ -14,8 +14,9 @@ class Functional_Net_SSH2Test extends PhpseclibFunctionalTestCase { $ssh = new SSH2($this->getEnv('SSH_HOSTNAME')); - $this->assertTrue( - is_object($ssh), + $this->assertInternalType( + 'object', + $ssh, 'Could not construct NET_SSH2 object.' ); diff --git a/tests/Unit/File/ANSITest.php b/tests/Unit/File/ANSITest.php index 5f356e11..6c785a5b 100644 --- a/tests/Unit/File/ANSITest.php +++ b/tests/Unit/File/ANSITest.php @@ -59,7 +59,7 @@ class Unit_File_ANSITest extends PhpseclibTestCase $screen = $ansi->getScreen(); $lines = explode("\r\n", $screen); - $this->assertSame(24, count($lines)); + $this->assertCount(24, $lines); $this->assertSame(str_repeat('z', 80), $lines[22]); } -} \ No newline at end of file +}