build($options); $data = $serializer->serialize($instance); $request = new CreateInvoiceRequest($options); $expected = $request->toArray(); self::assertEquals($expected, $data); } /** * @throws Exception */ public static function validDataProvider(): array { $metadata = new Metadata(); $metadata->test = 'test'; $result = [ [ [ 'payment_data' => [ 'amount' => new MonetaryAmount(Random::int(1, 1000000)), ], 'cart' => [ [ 'description' => Random::str(5, 128), 'price' => new MonetaryAmount(Random::int(1, 1000000)), 'discount_price' => null, 'quantity' => Random::int(1, 10), ] ], 'delivery_method_data' => null, 'expires_at' => new DateTime('+ 1 hour'), 'locale' => null, 'description' => null, 'metadata' => null, ], ], [ [ 'payment_data' => [ 'amount' => new MonetaryAmount(Random::int(1, 1000000)), 'save_payment_method' => true, 'description' => Random::str(5, 128), 'client_ip' => Internet::localIpv4(), ], 'cart' => [ new LineItem([ 'description' => Random::str(5, 128), 'price' => new MonetaryAmount(Random::int(1, 1000000)), 'discount_price' => null, 'quantity' => Random::int(1, 10), ]), ], 'delivery_method_data' => ['type' => 'self'], 'expires_at' => new DateTime('+ 1 day'), 'locale' => Random::value(['ru_RU', 'en_US', null]), 'description' => '', 'metadata' => [Random::str(1)], ], ], ]; for ($i = 0; $i < 10; $i++) { $even = ($i % 3); $request = [ 'payment_data' => new PaymentData([ 'amount' => new MonetaryAmount(Random::int(1, 1000000)), 'save_payment_method' => true, 'description' => Random::str(5, 128), 'client_ip' => Internet::localIpv4(), ]), 'cart' => [ $even ? [ 'description' => Random::str(5, 128), 'price' => new MonetaryAmount(Random::int(1, 1000000)), 'discount_price' => null, 'quantity' => Random::int(1, 10), ] : new LineItem([ 'description' => Random::str(5, 128), 'price' => new MonetaryAmount(Random::int(1, 1000000)), 'discount_price' => null, 'quantity' => Random::int(1, 10), ]), ], 'delivery_method_data' => $even ? ['type' => 'self'] : null, 'expires_at' => $even ? new DateTime('+ 1 month') : '2024-10-18T10:51:18.139Z', 'locale' => Random::value(['ru_RU', 'en_US', null]), 'description' => Random::str(5, 128), 'metadata' => $even ? $metadata : ['test' => 'test'], ]; $result[] = [$request]; } return $result; } }