-
Notifications
You must be signed in to change notification settings - Fork 15
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
Fixed image uploading. Both URL and a file #29
Conversation
Great job! Can you also add in the changes in the tests? This PR should fix #25 image bug |
Will be glad but first I need to learn how it works and where to make changes :) |
Added image upload to unit tests. But testing fails if I run it as is. Complain is:
Checked path and namespaces, even added require_once 'MockeryAssertionTrait.php'; to GuzzleIzettleClientTest.php but seems nothing works. PHP 7.2.15. Any thoughts ? |
Hi @korzol Can you tell me how you are running the tests? are you using the Make commands? I've checkout your pr locally and have come to the following conclusion:
If you run with the make command it should work. You can also check if you have mockery installed in your vendor directory. i've also left you some more feedback. 🤗 |
self::assertAttributeEquals($imageUrl, 'imageUrl', $productImageUpload); | ||
self::assertSame(['imageUrl' => $imageUrl], json_decode($productImageUpload->getPostBodyData(), true)); | ||
// self::assertSame(['imageUrl' => $imageUrl], json_decode($productImageUpload->getPostBodyData(), true)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove dead code
// self::assertSame(['imageUrl' => $imageUrl], json_decode($productImageUpload->getPostBodyData(), true)); |
self::assertAttributeEquals($imageUrl, 'imageUrl', $productImageUpload); | ||
self::assertSame(['imageUrl' => $imageUrl], json_decode($productImageUpload->getPostBodyData(), true)); | ||
// self::assertSame(['imageUrl' => $imageUrl], json_decode($productImageUpload->getPostBodyData(), true)); | ||
self::assertSame(['imageFormat' => $imageFormat, 'imageData' => $imageData], json_decode($productImageUpload->getPostBodyData(), true)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should fix this test
self::assertSame(['imageFormat' => $imageFormat, 'imageData' => $imageData], json_decode($productImageUpload->getPostBodyData(), true)); | |
self::assertSame(['imageFormat' => $imageFormat, 'imageUrl' => $imageUrl], json_decode($productImageUpload->getPostBodyData(), true)); |
]; | ||
|
||
$imageUrl = 'https://example.com/image.png'; | ||
$imageFormat = $allowedImageType[ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please make sure the code style is inline with the other files:
(alignment equal signs)
run make cs-fix
to fix automatically
public function byteArray(string $filename): array | ||
{ | ||
$data = file_get_contents($filename); | ||
$array = array(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please make sure the code style is inline with the other files:
(Short array syntax)
run make cs-fix
to fix automatically
} | ||
|
||
/** | ||
* Generate byte array similar to the one in C# and Java |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove unnecessary comment. It does not add any value.
@@ -31,7 +31,22 @@ public function __construct(string $filename) | |||
{ | |||
$this->validateFile($filename); | |||
$this->imageFormat = self::ALLOWED_FILE_TYPES[exif_imagetype($filename)]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add ext-exif
to composer.json as a required extension? i've missed this.
Hi @korzol Are you able to finish this PR? |
Hello @korzol, Is there any news about this PR ? |
Closed due to no response. i might fix this myself later on |
Hello
Thank you! You did a great job!
iZettle updated their API documentation. At least new there is correct URL to send images to.
Also some small changes like uuid in ImageClient was null.
Also now they require image type even for url, so I had to implement it somehow
Have a good day