|
1 | 1 | <?php namespace webservices\rest\unittest;
|
2 | 2 |
|
3 |
| -use webservices\rest\TypeMarshaller; |
4 |
| -use lang\Type; |
5 |
| -use lang\Primitive; |
6 | 3 | use lang\ArrayType;
|
| 4 | +use lang\ClassLoader; |
7 | 5 | use lang\MapType;
|
| 6 | +use lang\Primitive; |
| 7 | +use lang\Type; |
8 | 8 | use lang\XPClass;
|
9 |
| -use lang\ClassLoader; |
| 9 | +use util\Currency; |
10 | 10 | use util\Date;
|
11 |
| -use util\TimeZone; |
12 | 11 | use util\Money;
|
13 |
| -use util\Currency; |
| 12 | +use util\TimeZone; |
14 | 13 | use webservices\rest\RestMarshalling;
|
| 14 | +use webservices\rest\TypeMarshaller; |
15 | 15 | use webservices\rest\unittest\srv\fixture\Wallet;
|
16 | 16 |
|
17 | 17 | /**
|
@@ -51,28 +51,28 @@ static function __static() {
|
51 | 51 | #[@beforeClass]
|
52 | 52 | public static function defineWalletClassMarshaller() {
|
53 | 53 | self::$walletClass= new XPClass(Wallet::class);
|
54 |
| - self::$walletMarshaller= newinstance(TypeMarshaller::class, [], [ |
55 |
| - 'marshal' => function($wallet, $marshalling= null) { |
| 54 | + self::$walletMarshaller= newinstance(TypeMarshaller::class, [], '{ |
| 55 | + public function marshal($wallet, $marshalling= null) { |
56 | 56 | return $marshalling->marshal($wallet->values);
|
57 |
| - }, |
58 |
| - 'unmarshal' => function(\lang\Type $t, $input, $marshalling= null) { |
59 |
| - return $t->newInstance($marshalling->unmarshal(new \lang\ArrayType('util.Money'), $input)); |
60 | 57 | }
|
61 |
| - ]); |
| 58 | + public function unmarshal(\lang\Type $t, $input, $marshalling= null) { |
| 59 | + return $t->newInstance($marshalling->unmarshal(new \lang\ArrayType("util.Money"), $input)); |
| 60 | + } |
| 61 | + }'); |
62 | 62 | }
|
63 | 63 |
|
64 | 64 | #[@beforeClass]
|
65 | 65 | public static function defineMoneyMarshaller() {
|
66 |
| - self::$moneyMarshaller= newinstance(TypeMarshaller::class, [], [ |
67 |
| - 'marshal' => function($money, $marshalling= null) { |
| 66 | + self::$moneyMarshaller= newinstance(TypeMarshaller::class, [], '{ |
| 67 | + public function marshal($money, $marshalling= null) { |
68 | 68 | $amount= $money->amount();
|
69 |
| - return sprintf('%.2f %s', is_object($amount) ? $amount->doubleValue() : $amount, $money->currency()->name()); |
70 |
| - }, |
71 |
| - 'unmarshal' => function(\lang\Type $t, $input, $marshalling= null) { |
72 |
| - sscanf($input, '%f %s', $amount, $currency); |
| 69 | + return sprintf("%.2f %s", is_object($amount) ? $amount->doubleValue() : $amount, $money->currency()->name()); |
| 70 | + } |
| 71 | + public function unmarshal(\lang\Type $t, $input, $marshalling= null) { |
| 72 | + sscanf($input, "%f %s", $amount, $currency); |
73 | 73 | return $t->newInstance($amount, \util\Currency::getInstance($currency));
|
74 | 74 | }
|
75 |
| - ]); |
| 75 | + }'); |
76 | 76 | }
|
77 | 77 |
|
78 | 78 | #[@test]
|
|
0 commit comments