Skip to content

Commit

Permalink
Upgrade travis and more (pionl#11)
Browse files Browse the repository at this point in the history
* Added confirmation request to import settings.

* Parameter "confirmation_request" writing has been changed.

* Fixed incorrect namespace for confirmation request.

* Added support for contact purpose.

* Editing releases in readme.md.
Fix bad names in Purposes holder.

* New line in the end of file ConfirmationRequest.php.

* Updated travis.yml by composer minimum PHP version requirement.

* Upgrade PHPUnit to 7.5

* Clean from old PHPDoc and fix no assertions.

* Missing client property in Api class.

* Upgrade Guzzle to 7.2.

* File .editorconfig. New line at end of files.

* Support last tested guzzle and greater.
  • Loading branch information
stanislav-janu authored Dec 15, 2020
1 parent ba2aa04 commit 64eb47f
Show file tree
Hide file tree
Showing 37 changed files with 63 additions and 68 deletions.
9 changes: 9 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
; This file is for unifying the coding style for different editors and IDEs.
; More information at http://editorconfig.org

[*]
charset = utf-8
indent_style = space
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
9 changes: 4 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
language: php
php:
- '5.6'
- '7.0'
- '7.1'
- '7.3'
- '7.4'

before_script: composer install --dev
before_script: composer install

script: ./vendor/phpunit/phpunit/phpunit --configuration phpunit.xml
script: ./vendor/phpunit/phpunit/phpunit --configuration phpunit.xml
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@
"minimum-stability": "stable",
"require": {
"php": ">=7.3",
"guzzlehttp/guzzle": "^6.2"
"guzzlehttp/guzzle": ">=6.2"
},
"require-dev": {
"phpunit/phpunit": "^5.7",
"phpunit/phpunit": "^7.5",
"vlucas/phpdotenv": "^2.4"
}
}
12 changes: 1 addition & 11 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,10 @@
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false">
stopOnFailure="false">
<testsuites>
<testsuite name="Application Test Suite">
<directory>./tests/</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory suffix=".php">src/</directory>
</whitelist>
<exclude>
<directory>vendor/</directory>
<directory>tests/</directory>
</exclude>
</filter>
</phpunit>
3 changes: 3 additions & 0 deletions src/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ class Api
*/
private $apiUrl;

/** @var \GuzzleHttp\Client */
private $client;

/**
* Api constructor.
*
Expand Down
2 changes: 1 addition & 1 deletion src/Exceptions/JsonDataInvalidException.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ public static function throwIfInValid($arrayOrObject, $key, $functionCheck)

return $value;
}
}
}
2 changes: 1 addition & 1 deletion src/Exceptions/JsonDataMissingException.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ public static function throwIfSet($arrayOrObject, $key)
return $arrayOrObject->{$key};
}

}
}
2 changes: 1 addition & 1 deletion src/Exceptions/PropertyRequiredException.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ public function __construct($propertyName, $customMessage = null, $code = 500, E
parent::__construct($message, $code, $previous);
}

}
}
2 changes: 1 addition & 1 deletion src/Exceptions/RequestException.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ public function request()
{
return $this->request;
}
}
}
2 changes: 1 addition & 1 deletion src/Helpers/global_helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ function value($value, $onNullValue) {
}

return $value;
}
}
2 changes: 1 addition & 1 deletion src/Models/AbstractHolder.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ public function jsonSerialize()
{
return $this->toArray();
}
}
}
2 changes: 1 addition & 1 deletion src/Models/AbstractMapHolder.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ protected function insertEntry($entry)

return true;
}
}
}
2 changes: 1 addition & 1 deletion src/Models/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@ public function jsonSerialize()
return !is_null($val);
});
}
}
}
2 changes: 1 addition & 1 deletion tests/ApiClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,4 @@ public function testCustomBaseUri()
// Check if the URL is same
$this->assertEquals('test', $baseUri);
}
}
}
2 changes: 1 addition & 1 deletion tests/Mock/HolderMock.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ public function add($item)
$this->items[] = $item;
return $this;
}
}
}
2 changes: 1 addition & 1 deletion tests/Mock/ModelMock.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ public function toArray()
];
}

}
}
2 changes: 1 addition & 1 deletion tests/Mock/RequestMock.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ protected function options()
return ['test'];
}

}
}
5 changes: 2 additions & 3 deletions tests/Models/ModelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ public function testFromJSON()
'array' => []
]);

$this->assertObjectNotHasAttribute('unsupported', $model, 'A key should not be imported if not found in default
toArray data');
$this->assertObjectNotHasAttribute('unsupported', $model, 'A key should not be imported if not found in default toArray data');
$this->assertTrue($model->boolean);
$this->assertNull($model->null);
$this->assertEquals([], $model->array);
Expand All @@ -60,4 +59,4 @@ public function testFromJSONParseNull()
]);
$this->assertNull($model->array);
}
}
}
11 changes: 4 additions & 7 deletions tests/Request/AbstractRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ public function testResponseStatusCodeWithResponseError()
'The exception should use json message if Guzzle returns simple error');
$this->assertEquals(500, $exception->getCode(), 'Exception must have same code as status code');
$this->assertEquals(500, $exception->response()->statusCode());
$this->assertNotNull($exception->request(), 'Non 200 status code should have request -
passed from guzzle exception');
$this->assertNotNull($exception->request(), 'Non 200 status code should have request - passed from guzzle exception');
}

/**
Expand Down Expand Up @@ -90,8 +89,7 @@ public function testResponseStatusCode()
$this->assertEquals('Client error', $exception->getMessage(), 'The exception should use the Guzzles message');
$this->assertEquals(500, $exception->getCode(), 'Exception must have same code as status code');
$this->assertEquals(500, $exception->response()->statusCode());
$this->assertNotNull($exception->request(), 'Non 200 status code should have request -
passed from guzzle exception');
$this->assertNotNull($exception->request(), 'Non 200 status code should have request - passed from guzzle exception');
}

/**
Expand All @@ -111,8 +109,7 @@ public function testResponseStatusCodeWithJson()
$this->assertEquals('Client error: An error', $exception->getMessage(), 'The guzzle message is simple, append message');
$this->assertEquals(500, $exception->getCode(), 'Exception must have same code as status code');
$this->assertEquals(500, $exception->response()->statusCode());
$this->assertNotNull($exception->request(), 'Non 200 status code should have request -
passed from guzzle exception');
$this->assertNotNull($exception->request(), 'Non 200 status code should have request - passed from guzzle exception');
}

}
}
2 changes: 1 addition & 1 deletion tests/Request/Credentials/CredentialsLiveTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@ public function testSend401()
$this->assertNull($response->accountId(), 'Default value of accountId should be null');
}
}
}
}
2 changes: 1 addition & 1 deletion tests/Request/Credentials/CredentialsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ public function testSend()

$this->assertEquals(2, $response->accountId());
}
}
}
2 changes: 1 addition & 1 deletion tests/Request/CustomFields/Create/RequestLiveTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@ public function testSend()
$this->assertEquals('text', $customField->type);
$this->assertEquals('test', $customField->name);
}
}
}
2 changes: 1 addition & 1 deletion tests/Request/CustomFields/Create/RequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,4 @@ public function testConstructCustomField()
$this->assertNotNull($request->customField());
$this->assertEquals('test', $request->customField()->name, 'Custom field is not same as passed');
}
}
}
2 changes: 1 addition & 1 deletion tests/Request/CustomFields/CustomFieldTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,4 @@ public function testCreateValueEmpty()
$this->assertEquals(11, $importField->id);
$this->assertNull($importField->value);
}
}
}
2 changes: 1 addition & 1 deletion tests/Request/CustomFields/CustomFieldsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,4 @@ public function testExists()
$this->assertInstanceOf(CustomField::class, $customField);
$this->assertEquals(1, $customField->id);
}
}
}
2 changes: 1 addition & 1 deletion tests/Request/CustomFields/Exists/RequestLiveTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ public function testSend()

$this->assertTrue(is_object($customField), 'Not found');
}
}
}
3 changes: 1 addition & 2 deletions tests/Request/CustomFields/Exists/RequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,11 @@ public function testNotExistsWithoutResults()
"limit": 2
},
"data": [
]
}';

$customField = $this->request()->exists();

$this->assertFalse($customField, 'The exists should return false if not found');
}
}
}
2 changes: 1 addition & 1 deletion tests/Request/CustomFields/Search/RequestLiveTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@ public function testSend()
$this->assertNotNull($customField->id);
}
}
}
}
2 changes: 1 addition & 1 deletion tests/Request/CustomFields/Search/RequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -205,4 +205,4 @@ public function testQueryFilterByTypeFail()
//endregion


}
}
2 changes: 1 addition & 1 deletion tests/Request/Import/ContactListTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,4 @@ public function testJsonSerialize()
'status' => ContactList::CONFIRMED
], $this->list->jsonSerialize());
}
}
}
2 changes: 1 addition & 1 deletion tests/Request/Import/ContactTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,4 +193,4 @@ public function testJson()
$json
);
}
}
}
2 changes: 1 addition & 1 deletion tests/Request/Import/CustomFieldTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,4 @@ public function testAddOption()
$this->field->addOption(2);
$this->assertEquals([1, 2], $this->field->options);
}
}
}
3 changes: 2 additions & 1 deletion tests/Request/Import/ImportLiveTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public function testBasic() {
public function testContactImport()
{
// Uncomment if you want to try
$this->assertNull(null);
return;

$contactFull = new Contact('[email protected]');
Expand All @@ -50,4 +51,4 @@ public function testContactImport()
$this->assertEquals(201, $response->statusCode());
}

}
}
2 changes: 1 addition & 1 deletion tests/Request/Import/ImportTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,4 +141,4 @@ public function testChunkModeError()
$this->import->send();
}

}
}
2 changes: 1 addition & 1 deletion tests/Request/Import/PurposeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,4 @@ public function testDateTimeFormat()
$this->assertContains('Invalid date and time format', $exception->getMessage());
}
}
}
}
18 changes: 8 additions & 10 deletions tests/TestCase/ApiStubTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ protected function setUp()
* Creates a tests for send request that will check if correct parameters are send to clients request method
*
* @param AbstractRequest $request
* @param string|null|\PHPUnit_Framework_Constraint|mixed $endpointName
* @param string|null|\PHPUnit_Framework_Constraint|mixed $httpMethod
* @param string|null|\PHPUnit_Framework_Constraint|mixed $options
* @param string|null|mixed $endpointName
* @param string|null|mixed $httpMethod
* @param string|null|mixed $options
*
* @return \SmartEmailing\v3\Request\Response
*/
Expand All @@ -61,8 +61,8 @@ protected function createEndpointTest($request, $endpointName, $httpMethod = 'GE
/**
* Builds the response/client mocks and setups for a clients request call
*
* @param string|null|\PHPUnit_Framework_Constraint|mixed $endpointName
* @param string|null|\PHPUnit_Framework_Constraint|mixed $httpMethod
* @param string|null|mixed $endpointName
* @param string|null|mixed $httpMethod
* @param array $options
*/
protected function stubClientResponse($endpointName, $httpMethod = 'GET', $options = [])
Expand All @@ -89,9 +89,7 @@ protected function stubClientResponse($endpointName, $httpMethod = 'GET', $optio
/**
* Builds the correct constraint value based on input value
*
* @param string|null|\PHPUnit_Framework_Constraint|mixed $desiredValue
*
* @return \PHPUnit_Framework_Constraint_IsAnything|\PHPUnit_Framework_Constraint_IsEqual
* @param string|null|mixed $desiredValue
*/
protected function valueConstraint($desiredValue)
{
Expand Down Expand Up @@ -156,7 +154,7 @@ public function createSendErrorResponse($request, $responseText, $responseMessag
// Run the request
$request->send();

$this->fail('The send request should raise an exception when Guzzle raises RequestException
$this->fail('The send request should raise an exception when Guzzle raises RequestException
(non 200 status code) or API returns 200 status code with error status in json');
return null;
} catch (RequestException $exception) {
Expand Down Expand Up @@ -211,4 +209,4 @@ protected function assertResponse($response, $responseClass, $responseStatus, $r
$this->assertEquals($meta, $response->meta());
}

}
}
2 changes: 1 addition & 1 deletion tests/TestCase/BaseTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,4 @@ function env($key, $default = null)
}
return $value;
}
}
}

0 comments on commit 64eb47f

Please sign in to comment.