From b1c09e463367779a25d260c2283bd11db5cf3cb2 Mon Sep 17 00:00:00 2001 From: Gabriel Caruso Date: Thu, 7 Dec 2017 17:19:24 -0200 Subject: [PATCH] Refactoring tests --- .../AdsApi/AdWords/AdWordsServicesIntegrationTest.php | 2 +- tests/Google/AdsApi/AdWords/AdWordsSessionBuilderTest.php | 8 ++++---- tests/Google/AdsApi/AdWords/ReportSettingsBuilderTest.php | 4 ++-- .../Reporting/ReportDownloadResultDelegateTest.php | 2 +- tests/Google/AdsApi/Common/AdsSoapClientTest.php | 4 ++-- .../Google/AdsApi/Common/SuppressTriggerErrorTestCase.php | 4 ++-- tests/Google/AdsApi/Common/Util/MapEntriesTest.php | 2 +- tests/Google/AdsApi/Dfp/DfpSessionBuilderTest.php | 8 ++++---- tests/Google/AdsApi/Dfp/Util/v201711/CsvFilesTest.php | 8 ++++---- 9 files changed, 21 insertions(+), 21 deletions(-) diff --git a/tests/Google/AdsApi/AdWords/AdWordsServicesIntegrationTest.php b/tests/Google/AdsApi/AdWords/AdWordsServicesIntegrationTest.php index e26a0c860..77f64fd98 100755 --- a/tests/Google/AdsApi/AdWords/AdWordsServicesIntegrationTest.php +++ b/tests/Google/AdsApi/AdWords/AdWordsServicesIntegrationTest.php @@ -124,7 +124,7 @@ public function testGetCallToCampaignServiceReturnsResults( // Check that the campaign service (which is a SOAP client) has deserialized // the SOAP XML response to the Campaign object correctly. $actualCampaigns = $page->getEntries(); - $this->assertSame(count($expectedCampaigns), count($actualCampaigns)); + $this->assertCount(count($expectedCampaigns), $actualCampaigns); for ($i = 0; $i < count($actualCampaigns); $i++) { $expectedCampaign = $expectedCampaigns[$i]; diff --git a/tests/Google/AdsApi/AdWords/AdWordsSessionBuilderTest.php b/tests/Google/AdsApi/AdWords/AdWordsSessionBuilderTest.php index 10f5d66c9..daf3c41b4 100755 --- a/tests/Google/AdsApi/AdWords/AdWordsSessionBuilderTest.php +++ b/tests/Google/AdsApi/AdWords/AdWordsSessionBuilderTest.php @@ -122,8 +122,8 @@ public function testBuildFromDefaults() { $this->assertSame( 'ABcdeFGH93KL-NOPQ_STUv', $adWordsSession->getDeveloperToken()); $this->assertSame('report downloader', $adWordsSession->getUserAgent()); - $this->assertTrue(filter_var( - $adWordsSession->getEndpoint(), FILTER_VALIDATE_URL) !== false); + $this->assertNotFalse(filter_var( + $adWordsSession->getEndpoint(), FILTER_VALIDATE_URL)); $this->assertNull($adWordsSession->getClientCustomerId()); $this->assertNotNull($adWordsSession->isPartialFailure()); $this->assertNotNull($adWordsSession->isIncludeUtilitiesInUserAgent()); @@ -268,8 +268,8 @@ public function testBuildDefaults() { $adWordsSession->getOAuth2Credential()); $this->assertInstanceOf( LoggerInterface::class, $adWordsSession->getSoapLogger()); - $this->assertTrue(filter_var( - $adWordsSession->getEndpoint(), FILTER_VALIDATE_URL) !== false); + $this->assertNotFalse(filter_var( + $adWordsSession->getEndpoint(), FILTER_VALIDATE_URL)); $this->assertNull($adWordsSession->getClientCustomerId()); $this->assertNotNull($adWordsSession->isPartialFailure()); $this->assertNotNull($adWordsSession->isIncludeUtilitiesInUserAgent()); diff --git a/tests/Google/AdsApi/AdWords/ReportSettingsBuilderTest.php b/tests/Google/AdsApi/AdWords/ReportSettingsBuilderTest.php index b9817d596..4a3d7c742 100755 --- a/tests/Google/AdsApi/AdWords/ReportSettingsBuilderTest.php +++ b/tests/Google/AdsApi/AdWords/ReportSettingsBuilderTest.php @@ -17,7 +17,7 @@ namespace Google\AdsApi\Common; use Google\AdsApi\AdWords\ReportSettingsBuilder; -use PHPUnit_Framework_TestCase; +use PHPUnit\Framework\TestCase; /** * Unit tests for `ReportSettingsBuilder`. @@ -25,7 +25,7 @@ * @see ReportSettingsBuilder * @small */ -class ReportSettingsBuilderTest extends PHPUnit_Framework_TestCase { +class ReportSettingsBuilderTest extends TestCase { private $reportSettingsBuilder; diff --git a/tests/Google/AdsApi/AdWords/Reporting/ReportDownloadResultDelegateTest.php b/tests/Google/AdsApi/AdWords/Reporting/ReportDownloadResultDelegateTest.php index 99b692027..4600c0be6 100755 --- a/tests/Google/AdsApi/AdWords/Reporting/ReportDownloadResultDelegateTest.php +++ b/tests/Google/AdsApi/AdWords/Reporting/ReportDownloadResultDelegateTest.php @@ -82,7 +82,7 @@ public function testSaveToFile() { tempnam(sys_get_temp_dir(), 'criteria-report-') ); $this->reportDownloadResultDelegate->saveToFile($filePath); - $this->assertSame($this->fakeReport, file_get_contents($filePath)); + $this->assertStringEqualsFile($filePath, $this->fakeReport); } /** diff --git a/tests/Google/AdsApi/Common/AdsSoapClientTest.php b/tests/Google/AdsApi/Common/AdsSoapClientTest.php index f7015c43e..7fe1af839 100755 --- a/tests/Google/AdsApi/Common/AdsSoapClientTest.php +++ b/tests/Google/AdsApi/Common/AdsSoapClientTest.php @@ -16,7 +16,7 @@ */ namespace Google\AdsApi\Common; -use PHPUnit_Framework_TestCase; +use PHPUnit\Framework\TestCase; /** * Unit tests for `AdsSoapClient`. @@ -24,7 +24,7 @@ * @see AdsSoapClient * @small */ -class AdsSoapClientTest extends PHPUnit_Framework_TestCase { +class AdsSoapClientTest extends TestCase { /** * @covers Google\AdsApi\Common\AdsSoapClient::getLocalWsdlPath diff --git a/tests/Google/AdsApi/Common/SuppressTriggerErrorTestCase.php b/tests/Google/AdsApi/Common/SuppressTriggerErrorTestCase.php index 5481c5589..183b3d674 100755 --- a/tests/Google/AdsApi/Common/SuppressTriggerErrorTestCase.php +++ b/tests/Google/AdsApi/Common/SuppressTriggerErrorTestCase.php @@ -16,12 +16,12 @@ */ namespace Google\AdsApi\Common; -use PHPUnit_Framework_TestCase; +use PHPUnit\Framework\TestCase; /** * A test case that needs suppression of trigger_error(). */ -class SuppressTriggerErrorTestCase extends PHPUnit_Framework_TestCase { +class SuppressTriggerErrorTestCase extends TestCase { /** * @see PHPUnit_Framework_TestCase::setUp diff --git a/tests/Google/AdsApi/Common/Util/MapEntriesTest.php b/tests/Google/AdsApi/Common/Util/MapEntriesTest.php index bd831d6f3..53b428632 100755 --- a/tests/Google/AdsApi/Common/Util/MapEntriesTest.php +++ b/tests/Google/AdsApi/Common/Util/MapEntriesTest.php @@ -60,7 +60,7 @@ public function testFromAssociativeArray( array $expectedMapEntries, array $map) { $actualMapEntries = MapEntries::fromAssociativeArray($map, FakeMapEntry::class); - $this->assertSame(count($expectedMapEntries), count($actualMapEntries)); + $this->assertCount(count($expectedMapEntries), $actualMapEntries); foreach ($actualMapEntries as $i => $actualMapEntry) { $this->assertSame( diff --git a/tests/Google/AdsApi/Dfp/DfpSessionBuilderTest.php b/tests/Google/AdsApi/Dfp/DfpSessionBuilderTest.php index f714d4f5e..371425636 100755 --- a/tests/Google/AdsApi/Dfp/DfpSessionBuilderTest.php +++ b/tests/Google/AdsApi/Dfp/DfpSessionBuilderTest.php @@ -102,8 +102,8 @@ public function testBuildFromDefaults() { $this->assertSame('12345678', $dfpSession->getNetworkCode()); $this->assertSame( 'google report runner', $dfpSession->getApplicationName()); - $this->assertTrue( - filter_var($dfpSession->getEndpoint(), FILTER_VALIDATE_URL) !== false); + $this->assertNotFalse( + filter_var($dfpSession->getEndpoint(), FILTER_VALIDATE_URL)); $this->assertNotNull($dfpSession->getSoapSettings()); } @@ -224,8 +224,8 @@ public function testBuildDefaults() { $this->assertSame('12345678', $dfpSession->getNetworkCode()); $this->assertSame( 'Google report runner', $dfpSession->getApplicationName()); - $this->assertTrue( - filter_var($dfpSession->getEndpoint(), FILTER_VALIDATE_URL) !== false); + $this->assertNotFalse( + filter_var($dfpSession->getEndpoint(), FILTER_VALIDATE_URL)); $this->assertInstanceOf(FetchAuthTokenInterface::class, $dfpSession->getOAuth2Credential()); $this->assertNotNull($dfpSession->getSoapSettings()); diff --git a/tests/Google/AdsApi/Dfp/Util/v201711/CsvFilesTest.php b/tests/Google/AdsApi/Dfp/Util/v201711/CsvFilesTest.php index d8cbdc86c..1af5b58f9 100755 --- a/tests/Google/AdsApi/Dfp/Util/v201711/CsvFilesTest.php +++ b/tests/Google/AdsApi/Dfp/Util/v201711/CsvFilesTest.php @@ -16,7 +16,7 @@ */ namespace Google\AdsApi\Dfp\Util\v201711; -use PHPUnit_Framework_TestCase; +use PHPUnit\Framework\TestCase; /** * Unit tests for `CsvFiles`. @@ -24,7 +24,7 @@ * @see CsvFiles * @group small */ -class CsvFilesTest extends PHPUnit_Framework_TestCase { +class CsvFilesTest extends TestCase { const IN_MEMORY_FILE_PATH = 'php://temp/maxmemory:1024'; private $resultSet; @@ -86,12 +86,12 @@ public function testWriteCsvToStream() { // Verify that the data is consistent after writing and reading CSV. $expectedRowCount = count($this->resultSet); - $this->assertEquals($expectedRowCount, count($actualData)); + $this->assertCount($expectedRowCount, $actualData); for ($i = 0; $i < $expectedRowCount; $i++) { $expectedRow = $this->resultSet[$i]; $actualRow = $actualData[$i]; $expectedFieldCount = count($expectedRow); - $this->assertEquals($expectedFieldCount, count($actualRow)); + $this->assertCount($expectedFieldCount, $actualRow); for ($j = 0; $j < $expectedFieldCount; $j++) { $this->assertEquals($expectedRow[$j], $actualRow[$j], sprintf("Mismatch found at row %d, col %d\n", $i, $j));