xref: /PHP-8.0/ext/soap/tests/schema/schema064.phpt (revision c5401854)
1--TEST--
2SOAP XML Schema 64: standard date/time types
3--SKIPIF--
4<?php
5if (defined('PHP_WINDOWS_VERSION_MAJOR')) {
6    die('skip, windows has different TZ format');
7}
8require_once('skipif.inc'); ?>
9--FILE--
10<?php
11include "test_schema.inc";
12$schema = <<<EOF
13    <complexType name="testType">
14        <sequence>
15            <element name="dateTime" type="dateTime"/>
16            <element name="time" type="time"/>
17            <element name="date" type="date"/>
18            <element name="gYearMonth" type="gYearMonth"/>
19            <element name="gYear" type="gYear"/>
20            <element name="gMonthDay" type="gMonthDay"/>
21            <element name="gDay" type="gDay"/>
22            <element name="gMonth" type="gMonth"/>
23        </sequence>
24    </complexType>
25EOF;
26$date = gmmktime(1,2,3,4,5,1976);
27putenv('TZ=GMT');
28test_schema($schema,'type="tns:testType"',array(
29    'dateTime' => $date,
30    'time' => $date,
31    'date' => $date,
32    'gYearMonth' => $date,
33    'gYear' => $date,
34    'gMonthDay' => $date,
35    'gDay' => $date,
36    'gMonth' => $date
37));
38echo "ok";
39?>
40--EXPECTF--
41<?xml version="1.0" encoding="UTF-8"?>
42<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://test-uri/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body><ns1:test><testParam xsi:type="ns1:testType"><dateTime xsi:type="xsd:dateTime">1976-04-05T01:02:03Z</dateTime><time xsi:type="xsd:time">01:02:03Z</time><date xsi:type="xsd:date">1976-04-05Z</date><gYearMonth xsi:type="xsd:gYearMonth">1976-04Z</gYearMonth><gYear xsi:type="xsd:gYear">1976Z</gYear><gMonthDay xsi:type="xsd:gMonthDay">--04-05Z</gMonthDay><gDay xsi:type="xsd:gDay">---05Z</gDay><gMonth xsi:type="xsd:gMonth">--04--Z</gMonth></testParam></ns1:test></SOAP-ENV:Body></SOAP-ENV:Envelope>
43object(stdClass)#%d (8) {
44  ["dateTime"]=>
45  string(20) "1976-04-05T01:02:03Z"
46  ["time"]=>
47  string(9) "01:02:03Z"
48  ["date"]=>
49  string(11) "1976-04-05Z"
50  ["gYearMonth"]=>
51  string(8) "1976-04Z"
52  ["gYear"]=>
53  string(5) "1976Z"
54  ["gMonthDay"]=>
55  string(8) "--04-05Z"
56  ["gDay"]=>
57  string(6) "---05Z"
58  ["gMonth"]=>
59  string(7) "--04--Z"
60}
61ok
62