Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions core/components/minishop3/src/Controllers/Customer/Customer.php
Original file line number Diff line number Diff line change
Expand Up @@ -302,17 +302,6 @@ public function validate(string $key, mixed $value): mixed
return $response['data']['value'];
}

/**
* Get customer ID for order (legacy method)
*
* @deprecated Use getOrCreate() instead
* @return int Customer ID or 0 if not found/created
*/
public function getId(): int
{
return $this->getOrCreate();
}

public function create(array $customerData): msCustomer|null
{
// Allow plugins to modify data before creation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public function setEmailVerification(EmailVerificationService $service): void
*
* Used in:
* - Register API processor (explicit user registration)
* - Customer::getId() (automatic registration during checkout)
* - Customer::getOrCreate() (automatic registration during checkout)
*
* @param array $data Customer data:
* - email (required)
Expand Down
32 changes: 0 additions & 32 deletions core/components/minishop3/src/Services/Order/OrderService.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,38 +118,6 @@ public function updateProducts(msOrder $order): bool
return $order->save();
}

/**
* Handle order save with events
*
* @deprecated Logic moved to msOrder::save(), this method kept for backward compatibility
*
* @param msOrder $order
* @param bool|null $cacheFlag
* @return bool
*/
public function handleOrderSave(msOrder $order, ?bool $cacheFlag = null): bool
{
// Simply delegate call to msOrder::save()
// It already contains all event logic
return $order->save($cacheFlag);
}

/**
* Delete order with events
*
* @deprecated Logic moved to msOrder::remove(), this method kept for backward compatibility
*
* @param msOrder $order
* @param array $ancestors
* @return bool Deletion result
*/
public function removeOrder(msOrder $order, array $ancestors = []): bool
{
// Simply delegate call to msOrder::remove()
// It already contains all event logic
return $order->remove($ancestors);
}

/**
* Get order statistics
*
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php

declare(strict_types=1);

namespace MiniShop3\Tests\Unit\Regression;

use MiniShop3\Controllers\Customer\Customer;
use MiniShop3\Services\Order\OrderService;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;

/**
* Regression #357: deprecated pass-through wrappers must stay removed from core.
*
* The original OrderService::handleOrderSave() / removeOrder() and
* Customer::getId() wrappers were deleted in favor of calling msOrder::save() /
* msOrder::remove() and Customer::getOrCreate() directly. These assertions
* guard against accidental reintroduction via reflection only — they do not
* scan the source tree, which keeps the test fast and free of false positives
* from comments, lexicon strings, or unrelated modules.
*/
final class DeprecatedPassThroughRemovedTest extends TestCase
{
/**
* @return iterable<string, array{0: class-string, 1: string}>
*/
public static function removedPassThroughsProvider(): iterable
{
yield 'OrderService::handleOrderSave' => [OrderService::class, 'handleOrderSave'];
yield 'OrderService::removeOrder' => [OrderService::class, 'removeOrder'];
yield 'Customer::getId' => [Customer::class, 'getId'];
}

#[DataProvider('removedPassThroughsProvider')]
public function testDeprecatedPassThroughIsRemoved(string $class, string $method): void
{
self::assertFalse(
method_exists($class, $method),
sprintf('%s::%s() must remain removed (deprecated pass-through).', $class, $method)
);

$reflection = new \ReflectionClass($class);
self::assertFalse(
$reflection->hasMethod($method),
sprintf('%s::%s() must not be redeclared (checked via reflection).', $class, $method)
);
}
}