Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Part 1] Modernise package and tests #91

Merged
merged 9 commits into from
Apr 24, 2024
Merged

Conversation

ryanmab
Copy link

@ryanmab ryanmab commented Apr 24, 2024

Description

Every once in awhile, when Dependabot bumps a dependency, I get reminded this repo exists. And what immediately follows is a crippling sense of anxiety that its very out of date, CI is broken, I'm pretty sure this is long since forgotten about (minus me and Sheamus who occasionally get dependency bumps), and tons of other things.

Upstream looks abandoned, so we should probably investigate moving off of this package at some point (although this isn't a particularly complex, so I'm not that worried).

Either way, I'm just trying to get the package back into shape now (i.e. CI working, more modern package standard, etc). Pretty sure this should have no runtime impact on the package, which is good because the monolith pulls in dev-master.

I'll look to Rector this into PHP 8.3 shape in a new PR when the test harness is working.

Deployment Notes

I'm expecting that Dependabot will go on a mini rampage of PR bumps when this is merged, as I've moved us from PHP 7.3 to PHP 8.2.

@@ -27,13 +33,13 @@ jobs:
${{ runner.os }}-php-

- name: Install dependencies
run: composer install --prefer-dist --no-progress --no-suggest
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This options deprecated

@@ -12,11 +12,23 @@
"guzzlehttp/guzzle": "^7.0.1",
"http-interop/http-factory-guzzle": "^1.0.0"
},
"minimum-stability": "stable",
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bumped to stable - makes me feel much better.

"php": ">=7.3",
"php": "^8.2",
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given tests are passing, and we're running this in a PHP 8.2 env (the platform) I think we're fine.

"Snowcap\\Emarsys\\Tests\\Unit\\": "tests/Unit/Suites/",
"Snowcap\\Emarsys\\Tests\\Integration\\": "tests/Integration/Suites/"
}
},
Copy link
Author

@ryanmab ryanmab Apr 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PHPStorm was unhappy with the namespaces. This should fix them. I moved us to PSR-4, which is why the src directory is now root instead of src/Snowcap/Emarsys/

@@ -337,6 +340,6 @@ public function testItReturnsEmailResponseSummary(): void
*/
private function createExpectedResponse(string $fileName)
{
return file_get_contents(__DIR__ . '/TestData/' . $fileName . '.json');
return Utils::streamFor(file_get_contents(__DIR__ . '/TestData/' . $fileName . '.json'));
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Guzzle only returns streams now. Rather than just plain old strings.

Comment on lines +3 to +9
on:
push:
branches:
- main

pull_request:
types: [ opened, synchronize, reopened ]
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We were running the CI on push and PR, which didn't make much sense.

Comment on lines 43 to 45
env: # Set the secrets as environment variables
EMARSYS_API_USERNAME: ${{ secrets.EMARSYS_API_USERNAME }}
EMARSYS_API_SECRET: ${{ secrets.EMARSYS_API_SECRET }}
Copy link
Author

@ryanmab ryanmab Apr 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer our integration tests didn't use Emarsys directly (I didn't realise it did until now).

Not on my agenda for today, but will probably change it to a mock server of some sort.

@ryanmab ryanmab changed the title Modernise package [Part 1] Modernise package and tests Apr 24, 2024
@@ -1,17 +1,15 @@
<?xml version="1.0"?>
<phpunit
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're on PHPUnit 9 and it was upset at some of the configs.

@@ -0,0 +1,10 @@
## Description
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shamelessly stolen from the monoliths repo.

@@ -126,7 +127,7 @@ public function testItAddsChoicesMapping(): void
public function testItThrowsAnExceptionIfFieldDoesNotExist(): void
{
$this->expectException(ClientException::class);
$this->expectErrorMessage('Unrecognized field name "non-existing-field-name"');
$this->expectExceptionMessage('Unrecognized field name "non-existing-field-name"');
Copy link
Author

@ryanmab ryanmab Apr 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

expectErrorMessage is deprecated, and will be removed in PHPUnit 10. For our purposes expectExceptionMessage should work the same.

@ryanmab ryanmab self-assigned this Apr 24, 2024
@ryanmab ryanmab marked this pull request as ready for review April 24, 2024 09:50
Copy link

@gabriel-breda gabriel-breda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good, thanks for updating it 👍

@ohallors
Copy link

Good improvements, thanks for not letting it gather more debt.

@ryanmab ryanmab mentioned this pull request Apr 24, 2024
@ryanmab ryanmab merged commit f7993bd into master Apr 24, 2024
1 check passed
@ryanmab ryanmab deleted the chore/modernise-package branch April 24, 2024 11:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants