Skip to content

Commit

Permalink
Merge pull request #415 from carusogabriel/refactoring-tests
Browse files Browse the repository at this point in the history
Refactoring tests
  • Loading branch information
fiboknacky committed Dec 13, 2017
2 parents 6e1d7f7 + b1c09e4 commit 676b722
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
8 changes: 4 additions & 4 deletions tests/Google/AdsApi/AdWords/AdWordsSessionBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -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());
Expand Down
4 changes: 2 additions & 2 deletions tests/Google/AdsApi/AdWords/ReportSettingsBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@
namespace Google\AdsApi\Common;

use Google\AdsApi\AdWords\ReportSettingsBuilder;
use PHPUnit_Framework_TestCase;
use PHPUnit\Framework\TestCase;

/**
* Unit tests for `ReportSettingsBuilder`.
*
* @see ReportSettingsBuilder
* @small
*/
class ReportSettingsBuilderTest extends PHPUnit_Framework_TestCase {
class ReportSettingsBuilderTest extends TestCase {

private $reportSettingsBuilder;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions tests/Google/AdsApi/Common/AdsSoapClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@
*/
namespace Google\AdsApi\Common;

use PHPUnit_Framework_TestCase;
use PHPUnit\Framework\TestCase;

/**
* Unit tests for `AdsSoapClient`.
*
* @see AdsSoapClient
* @small
*/
class AdsSoapClientTest extends PHPUnit_Framework_TestCase {
class AdsSoapClientTest extends TestCase {

/**
* @covers Google\AdsApi\Common\AdsSoapClient::getLocalWsdlPath
Expand Down
4 changes: 2 additions & 2 deletions tests/Google/AdsApi/Common/SuppressTriggerErrorTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/Google/AdsApi/Common/Util/MapEntriesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
8 changes: 4 additions & 4 deletions tests/Google/AdsApi/Dfp/DfpSessionBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}

Expand Down Expand Up @@ -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());
Expand Down
8 changes: 4 additions & 4 deletions tests/Google/AdsApi/Dfp/Util/v201711/CsvFilesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@
*/
namespace Google\AdsApi\Dfp\Util\v201711;

use PHPUnit_Framework_TestCase;
use PHPUnit\Framework\TestCase;

/**
* Unit tests for `CsvFiles`.
*
* @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;
Expand Down Expand Up @@ -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));
Expand Down

0 comments on commit 676b722

Please sign in to comment.