This commit is contained in:
2026-09-15 10:26:34 +08:00
commit ecf36afa56
10493 changed files with 1404888 additions and 0 deletions
@@ -0,0 +1,52 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\TestModule3\Service\V1\Entity;
class Parameter extends \Magento\Framework\Api\AbstractExtensibleObject
{
/**
* Get Name.
*
* @return string $name
*/
public function getName()
{
return $this->_data['name'];
}
/**
* Set Name.
*
* @param string $name
* @return $this
*/
public function setName($name)
{
return $this->setData('name', $name);
}
/**
* Get value.
*
* @return string $value
*/
public function getValue()
{
return $this->_data['value'];
}
/**
* Set value.
*
* @param string $value
* @return $this
*/
public function setValue($value)
{
return $this->setData('value', $value);
}
}
@@ -0,0 +1,52 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\TestModule3\Service\V1\Entity;
class WrappedErrorParameter extends \Magento\Framework\Api\AbstractExtensibleObject
{
/**
* Get field name.
*
* @return string $name
*/
public function getFieldName()
{
return $this->_data['field_name'];
}
/**
* Get value.
*
* @return string $value
*/
public function getValue()
{
return $this->_data['value'];
}
/**
* Set field name.
*
* @param string $fieldName
* @return $this
*/
public function setFieldName($fieldName)
{
return $this->setData('field_name', $fieldName);
}
/**
* Set value.
*
* @param string $value
* @return $this
*/
public function setValue($value)
{
return $this->setData('value', $value);
}
}
@@ -0,0 +1,116 @@
<?php
/**
* Implementation of a test service for error handling testing
*
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\TestModule3\Service\V1;
use Magento\Framework\Exception\AuthorizationException;
use Magento\Framework\Exception\InputException;
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\Exception\NoSuchEntityException;
use Magento\TestModule3\Service\V1\Entity\Parameter;
use Magento\TestModule3\Service\V1\Entity\ParameterFactory;
class Error implements \Magento\TestModule3\Service\V1\ErrorInterface
{
/**
* @var ParameterFactory
*/
protected $parameterFactory;
/**
* @param ParameterFactory $parameterFactory
*/
public function __construct(ParameterFactory $parameterFactory)
{
$this->parameterFactory = $parameterFactory;
}
/**
* {@inheritdoc}
*/
public function success()
{
return $this->parameterFactory->create()->setName('id')->setValue('a good id');
}
/**
* {@inheritdoc}
*/
public function resourceNotFoundException()
{
throw new NoSuchEntityException(
__(
'Resource with ID "%1" not found.',
'resourceY'
)
);
}
/**
* {@inheritdoc}
*/
public function serviceException()
{
throw new LocalizedException(__('Generic service exception %1', 3456));
}
/**
* {@inheritdoc}
*/
public function authorizationException()
{
throw new AuthorizationException(__("The consumer isn't authorized to access %1.", 'resourceN'));
}
/**
* {@inheritdoc}
*/
public function webapiException()
{
throw new \Magento\Framework\Webapi\Exception(
__('Service not found'),
5555,
\Magento\Framework\Webapi\Exception::HTTP_NOT_FOUND
);
}
/**
* {@inheritdoc}
*/
public function otherException()
{
throw new \Exception('Non service exception', 5678);
}
/**
* {@inheritdoc}
*/
public function returnIncompatibleDataType()
{
return "incompatibleDataType";
}
/**
* {@inheritdoc}
*/
public function inputException($wrappedErrorParameters)
{
$exception = new InputException();
if ($wrappedErrorParameters) {
foreach ($wrappedErrorParameters as $error) {
$exception->addError(
__(
'Invalid value of "%value" provided for the %fieldName field.',
['fieldName' => $error->getFieldName(), 'value' => $error->getValue()]
)
);
}
}
throw $exception;
}
}
@@ -0,0 +1,52 @@
<?php
/**
* Interface for a test service for error handling testing
*
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\TestModule3\Service\V1;
interface ErrorInterface
{
/**
* @return \Magento\TestModule3\Service\V1\Entity\Parameter
*/
public function success();
/**
* @return int Status
*/
public function resourceNotFoundException();
/**
* @return int Status
*/
public function serviceException();
/**
* @return int Status
*/
public function authorizationException();
/**
* @return int Status
*/
public function webapiException();
/**
* @return int Status
*/
public function otherException();
/**
* @return int Status
*/
public function returnIncompatibleDataType();
/**
* @param \Magento\TestModule3\Service\V1\Entity\WrappedErrorParameter[] $wrappedErrorParameters
* @return int Status
*/
public function inputException($wrappedErrorParameters);
}