Conversation
8a5e2cf to
4e03481
Compare
4e03481 to
8dac6a5
Compare
8dac6a5 to
85a616c
Compare
…anguageCreateStruct`
…anguageCreateStruct`
…anguageCreateStruct`
…lid language code tests
90267e6 to
4f830d7
Compare
…l` instead of `IbexaSolrTestKernel`
…Kernel` and added `CoreSolrTestKernel` implementation
|
| #[Assert\NotBlank] | ||
| #[Assert\Regex('~^[a-zA-Z\_\-]+$~')] | ||
| public ?string $languageCode = null; |
There was a problem hiding this comment.
Aren't we making a slight BC break here? Or maybe we are validating if later on on the UI side? POV ping @alongosz.
There was a problem hiding this comment.
Technically it can be a BC break if someone has migrations that were executing successfully until this regular expression assertion is introduced.
That said, as mentioned in the Jira ticket, creating certain languages (for example, with . as code) breaks the application entirely.
| * @copyright Copyright (C) Ibexa AS. All rights reserved. | ||
| * @license For full copyright and license information view LICENSE file distributed with this source code. | ||
| */ | ||
|
|
There was a problem hiding this comment.
Missing declaring strict types.
| if ($value instanceof ValueObject) { | ||
| self::assertStructPropertiesCorrect($value, $actualObject->$propertyName[$key]); | ||
| } else { | ||
| self::assertPropertiesEqual("$propertyName\[$key\]", $value, $actualObject->$propertyName[$key]); |
There was a problem hiding this comment.
| self::assertPropertiesEqual("$propertyName\[$key\]", $value, $actualObject->$propertyName[$key]); | |
| self::assertPropertiesEqual( | |
| "$propertyName\[$key\]", | |
| $value, | |
| $actualObject->$propertyName[$key] | |
| ); |
| * | ||
| * If the property type is array, it will be sorted before comparison. | ||
| * | ||
| * @TODO: introduced because of randomly failing tests, ref: https://issues.ibexa.co/browse/EZP-21734 |
There was a problem hiding this comment.
I don't think this is relevant anymore, or?
| $languageService->createLanguage($languageCreate); | ||
| /* END: Use Case */ | ||
| $this->expectException(InvalidArgumentException::class); | ||
| $this->expectExceptionMessage('Argument \'languageCreateStruct\' is invalid: language with the "nor-NO" language code already exists'); |
There was a problem hiding this comment.
| $this->expectExceptionMessage('Argument \'languageCreateStruct\' is invalid: language with the "nor-NO" language code already exists'); | |
| $this->expectExceptionMessage( | |
| 'Argument \'languageCreateStruct\' is invalid: language with the "nor-NO" language code already exists' | |
| ); |
| * @covers \Ibexa\Contracts\Core\Repository\LanguageService::loadLanguageListById | ||
| * | ||
| * @depends testCreateLanguage | ||
| * @testWith ["."] |
There was a problem hiding this comment.
Why this instead of dataProvider?
There was a problem hiding this comment.
It's simpler.
It will also look a lot better with attributes:
#[TestWith(['EUR'])]
#[TestWith(['USD'])]
#[TestWith([''])]
#[TestWith(['pln'])]
public function foo(string $currency) {
}There was a problem hiding this comment.
The one you posted looks even better.
| * @copyright Copyright (C) Ibexa AS. All rights reserved. | ||
| * @license For full copyright and license information view LICENSE file distributed with this source code. | ||
| */ | ||
|
|
There was a problem hiding this comment.
| declare(strict_types=1); |
|
PHPStan is failing. |



Description:
This PR adds metadata to
LanguageCreateStruct, with regex condition for the shape of the language code.Additionally, it refactors
LanguageServiceTestcode to use newer integration test setup, since the original one was usingDummyValidatorservice, which prevented the test from performing correctly.Tested manually against a migration:
Result:

Technically, operations that directly preceed the validator could be moved into validator itself as well (is name empty, is code empty, is code used already?), but I opted not to - since they would introduce more complexity to this PR. Can be done as a follow up if desired.
For QA:
Documentation: