diff --git a/composer.json b/composer.json index 8476209..14e60fb 100644 --- a/composer.json +++ b/composer.json @@ -34,7 +34,7 @@ "autoload": { "psr-4": { "RetailCrm\\Mg\\": ["src/", "tests/"], - "RetailCrm\\Common\\": "src/" + "RetailCrm\\Common\\": ["src/", "tests/"] }, "files": ["extra/autoloader.php"] }, diff --git a/src/Register.php b/src/Register.php index cc2801f..a1dfe1b 100644 --- a/src/Register.php +++ b/src/Register.php @@ -14,6 +14,7 @@ namespace RetailCrm\Common; use JMS\Serializer\Annotation\Accessor; +use JMS\Serializer\Annotation\SerializedName; use JMS\Serializer\Annotation\SkipWhenEmpty; use JMS\Serializer\Annotation\Type; use Symfony\Component\Validator\Constraints as Assert; @@ -43,6 +44,7 @@ class Register * * @Type("string") * @Accessor(getter="getIntegrationCode",setter="setIntegrationCode") + * @SerializedName("integrationCode") * * @Assert\NotBlank */ @@ -84,6 +86,7 @@ class Register * * @Type("string") * @Accessor(getter="getClientId",setter="setClientId") + * @SerializedName("clientId") * * @Assert\NotBlank */ @@ -94,6 +97,7 @@ class Register * * @Type("string") * @Accessor(getter="getBaseUrl",setter="setBaseUrl") + * @SerializedName("baseUrl") * * @Assert\NotBlank * @Assert\Url( @@ -132,6 +136,7 @@ class Register * * @Type("array") * @Accessor(getter="getAvailableCountries",setter="setAvailableCountries") + * @SerializedName("availableCountries") * @SkipWhenEmpty */ private $availableCountries; diff --git a/src/Serializer.php b/src/Serializer.php index bda71e7..0ef3805 100644 --- a/src/Serializer.php +++ b/src/Serializer.php @@ -44,7 +44,7 @@ class Serializer { $serialized = null; $serializer = SerializerBuilder::create()->build(); - $context = self::getContext(); + $context = self::getContext(false); switch ($serialize) { case self::S_ARRAY: @@ -93,7 +93,7 @@ class Serializer * * @return DeserializationContext|SerializationContext */ - private static function getContext(bool $deserialization = false) + private static function getContext(bool $deserialization) { if ($deserialization) { $context = new DeserializationContext(); diff --git a/tests/Common/Tests/RegisterTest.php b/tests/Common/Tests/RegisterTest.php new file mode 100644 index 0000000..18681a7 --- /dev/null +++ b/tests/Common/Tests/RegisterTest.php @@ -0,0 +1,51 @@ + + * @license https://opensource.org/licenses/MIT MIT License + * @link http://help.retailcrm.pro/docs/Developers + */ + +namespace RetailCrm\Common\Tests; + +use RetailCrm\Common\Register; +use PHPUnit\Framework\TestCase; + +/** + * Class RegisterTest + * + * @package RetailCrm\Mg\Bot\Tests + * @author retailCRM + * @license https://opensource.org/licenses/MIT MIT License + * @link http://help.retailcrm.pro/docs/Developers + */ +class RegisterTest extends TestCase +{ + + /** + * testGetArrayConfiguration + */ + public function testGetArrayConfiguration() + { + $register = new Register(); + $register->setAccountUrl('https://example.com/settings'); + $register->setActions(['ativity' => '/activity']); + $register->setActive(true); + $register->setBaseUrl('http:s//example.com'); + $register->setClientId(hash('ripemd160', time())); + $register->setCode('somecode'); + $register->setIntegrationCode('somecode'); + $register->setLogo('https://example.com/logo.svg'); + $register->setName('somename'); + + $array = $register->getArrayConfiguration(); + + self::assertArrayHasKey('baseUrl', $array); + self::assertArrayHasKey('integrationCode', $array); + self::assertArrayHasKey('clientId', $array); + } +}