Skip to content

Commit

Permalink
Merge "REST: Rename PropertyEditSummary"
Browse files Browse the repository at this point in the history
  • Loading branch information
jenkins-bot authored and Gerrit Code Review committed Oct 19, 2024
2 parents 231ac94 + 6bd92cf commit 763c93b
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use Wikibase\Repo\RestApi\Application\UseCases\UpdateExceptionHandler;
use Wikibase\Repo\RestApi\Application\UseCases\UseCaseError;
use Wikibase\Repo\RestApi\Domain\Model\EditMetadata;
use Wikibase\Repo\RestApi\Domain\Model\PropertyEditSummary;
use Wikibase\Repo\RestApi\Domain\Model\PatchPropertyEditSummary;
use Wikibase\Repo\RestApi\Domain\Services\PropertyRetriever;
use Wikibase\Repo\RestApi\Domain\Services\PropertyUpdater;
use Wikibase\Repo\RestApi\Domain\Services\PropertyWriteModelRetriever;
Expand Down Expand Up @@ -86,7 +86,7 @@ public function execute( PatchPropertyRequest $request ): PatchPropertyResponse
$providedMetadata->getTags(),
$providedMetadata->isBot(),
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable
PropertyEditSummary::newPatchSummary( $providedMetadata->getComment(), $originalProperty, $patchedProperty )
PatchPropertyEditSummary::newSummary( $providedMetadata->getComment(), $originalProperty, $patchedProperty )
)
) );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,22 @@
/**
* @license GPL-2.0-or-later
*/
class PropertyEditSummary implements EditSummary {
class PatchPropertyEditSummary implements EditSummary {

private string $editAction;
private ?string $userComment;
private Property $patchedProperty;
private Property $originalProperty;

public function __construct( string $editAction, ?string $userComment, Property $originalProperty, Property $patchedProperty ) {
$this->editAction = $editAction;
public function __construct( ?string $userComment, Property $originalProperty, Property $patchedProperty ) {
$this->editAction = self::PATCH_ACTION;
$this->userComment = $userComment;
$this->originalProperty = $originalProperty;
$this->patchedProperty = $patchedProperty;
}

public static function newPatchSummary( ?string $userComment, Property $originalProperty, Property $patchedProperty ): self {
return new self( self::PATCH_ACTION, $userComment, $originalProperty, $patchedProperty );
public static function newSummary( ?string $userComment, Property $originalProperty, Property $patchedProperty ): self {
return new self( $userComment, $originalProperty, $patchedProperty );
}

public function getEditAction(): string {
Expand Down
4 changes: 2 additions & 2 deletions repo/rest-api/src/Infrastructure/EditSummaryFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
use Wikibase\Repo\RestApi\Domain\Model\LabelEditSummary;
use Wikibase\Repo\RestApi\Domain\Model\LabelsEditSummary;
use Wikibase\Repo\RestApi\Domain\Model\PatchItemEditSummary;
use Wikibase\Repo\RestApi\Domain\Model\PropertyEditSummary;
use Wikibase\Repo\RestApi\Domain\Model\PatchPropertyEditSummary;
use Wikibase\Repo\RestApi\Domain\Model\SitelinkEditSummary;
use Wikibase\Repo\RestApi\Domain\Model\SitelinksEditSummary;
use Wikibase\Repo\RestApi\Domain\Model\StatementEditSummary;
Expand Down Expand Up @@ -48,7 +48,7 @@ public function format( EditSummary $summary ): string {

// phpcs:ignore Generic.Metrics.CyclomaticComplexity
private function convertToFormattableSummary( EditSummary $editSummary ): FormatableSummary {
if ( $editSummary instanceof PropertyEditSummary ) {
if ( $editSummary instanceof PatchPropertyEditSummary ) {
return $this->wholeEntityEditSummaryConverter->newSummaryForPropertyPatch( $editSummary );
} elseif ( $editSummary instanceof LabelsEditSummary ) {
return $this->termsEditSummaryConverter->convertLabelsEditSummary( $editSummary );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Wikibase\Lib\Summary;
use Wikibase\Repo\ChangeOp\ChangedLanguagesCounter;
use Wikibase\Repo\RestApi\Domain\Model\PatchItemEditSummary;
use Wikibase\Repo\RestApi\Domain\Model\PropertyEditSummary;
use Wikibase\Repo\RestApi\Domain\Model\PatchPropertyEditSummary;

/**
* @license GPL-2.0-or-later
Expand All @@ -16,7 +16,7 @@ class WholeEntityEditSummaryToFormattableSummaryConverter {

use ModifiedLanguageCodes;

public function newSummaryForPropertyPatch( PropertyEditSummary $editSummary ): Summary {
public function newSummaryForPropertyPatch( PatchPropertyEditSummary $editSummary ): Summary {
$originalProperty = $editSummary->getOriginalProperty();
$patchedProperty = $editSummary->getPatchedProperty();
$hasStatementsChanged = !$patchedProperty->getStatements()->equals( $originalProperty->getStatements() );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
use Wikibase\Repo\RestApi\Application\Validation\StatementsValidator;
use Wikibase\Repo\RestApi\Application\Validation\StatementValidator;
use Wikibase\Repo\RestApi\Domain\Model\EditMetadata;
use Wikibase\Repo\RestApi\Domain\Model\PropertyEditSummary;
use Wikibase\Repo\RestApi\Domain\Model\PatchPropertyEditSummary;
use Wikibase\Repo\RestApi\Domain\Model\User;
use Wikibase\Repo\RestApi\Domain\ReadModel\Aliases;
use Wikibase\Repo\RestApi\Domain\ReadModel\Description;
Expand Down Expand Up @@ -150,7 +150,7 @@ public function testHappyPath(): void {
new EditMetadata(
$editTags,
$isBot,
PropertyEditSummary::newPatchSummary(
PatchPropertyEditSummary::newSummary(
$comment,
$originalProperty,
$propertyRepo->getPropertyWriteModel( $propertyId )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
use Wikibase\Repo\RestApi\Domain\Model\LabelEditSummary;
use Wikibase\Repo\RestApi\Domain\Model\LabelsEditSummary;
use Wikibase\Repo\RestApi\Domain\Model\PatchItemEditSummary;
use Wikibase\Repo\RestApi\Domain\Model\PropertyEditSummary;
use Wikibase\Repo\RestApi\Domain\Model\PatchPropertyEditSummary;
use Wikibase\Repo\RestApi\Domain\Model\SitelinkEditSummary;
use Wikibase\Repo\RestApi\Domain\Model\SitelinksEditSummary;
use Wikibase\Repo\RestApi\Domain\Model\StatementEditSummary;
Expand Down Expand Up @@ -249,7 +249,7 @@ public function testGivenDescriptionsEditSummary_usesEditSummaryConverter(): voi
}

public function testPropertyEditSummary_usesEditSummaryConverter(): void {
$propertyEditSummary = $this->createStub( PropertyEditSummary::class );
$propertyEditSummary = $this->createStub( PatchPropertyEditSummary::class );
$converter = $this->createStub( TermsEditSummaryToFormattableSummaryConverter::class );

$editSummaryConverter = $this->createMock( WholeEntityEditSummaryToFormattableSummaryConverter::class );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
use Wikibase\DataModel\Term\TermList;
use Wikibase\DataModel\Tests\NewStatement;
use Wikibase\Lib\Summary;
use Wikibase\Repo\RestApi\Domain\Model\PropertyEditSummary;
use Wikibase\Repo\RestApi\Domain\Model\PatchPropertyEditSummary;
use Wikibase\Repo\RestApi\Infrastructure\WholeEntityEditSummaryToFormattableSummaryConverter;
use Wikibase\Repo\WikibaseRepo;

Expand All @@ -27,7 +27,7 @@ class WholeEntityEditSummaryToFormattableSummaryConverterTest extends TestCase {
/**
* @dataProvider propertyEditSummaryProvider
*/
public function testPatchPropertyEditSummary( PropertyEditSummary $editSummary, Summary $expectedSummary ): void {
public function testPatchPropertyEditSummary( PatchPropertyEditSummary $editSummary, Summary $expectedSummary ): void {
$editSummaryFormatter = new WholeEntityEditSummaryToFormattableSummaryConverter();
$this->assertEquals( $expectedSummary, $editSummaryFormatter->newSummaryForPropertyPatch( $editSummary ) );
}
Expand All @@ -38,7 +38,7 @@ public function propertyEditSummaryProvider(): Generator {
$originalProperty = new Property( $propertyId, new Fingerprint(), 'string', null );

yield 'patch property with labels and user comment' => [
PropertyEditSummary::newPatchSummary(
PatchPropertyEditSummary::newSummary(
$userComment,
$originalProperty,
new Property(
Expand All @@ -52,7 +52,7 @@ public function propertyEditSummaryProvider(): Generator {
];

yield 'patch property with just statement and no user comment' => [
PropertyEditSummary::newPatchSummary(
PatchPropertyEditSummary::newSummary(
null,
$originalProperty,
new Property(
Expand All @@ -66,7 +66,7 @@ public function propertyEditSummaryProvider(): Generator {
];

yield 'patch property with statement, labels, descriptions, and user comment' => [
PropertyEditSummary::newPatchSummary(
PatchPropertyEditSummary::newSummary(
$userComment,
$originalProperty,
new Property(
Expand All @@ -83,7 +83,7 @@ public function propertyEditSummaryProvider(): Generator {
];

yield 'patch property with different languages of labels and descriptions ' => [
PropertyEditSummary::newPatchSummary(
PatchPropertyEditSummary::newSummary(
$userComment,
$originalProperty,
new Property(
Expand All @@ -103,7 +103,7 @@ public function propertyEditSummaryProvider(): Generator {
];

yield 'patch property with long labels list, statement, and no user comment' => [
PropertyEditSummary::newPatchSummary(
PatchPropertyEditSummary::newSummary(
null,
$originalProperty,
new Property(
Expand All @@ -121,7 +121,7 @@ public function propertyEditSummaryProvider(): Generator {
];

yield 'patch property with long labels list and user comment' => [
PropertyEditSummary::newPatchSummary(
PatchPropertyEditSummary::newSummary(
$userComment,
$originalProperty,
new Property(
Expand Down

0 comments on commit 763c93b

Please sign in to comment.