xref: /PHP-8.1/ext/phar/tests/phar_oo_001.phpt (revision 74859783)
1--TEST--
2Phar object: basics
3--EXTENSIONS--
4phar
5--INI--
6phar.require_hash=0
7phar.readonly=0
8--FILE--
9<?php
10
11require_once 'files/phar_oo_test.inc';
12
13$phar = new Phar($fname);
14var_dump($phar->getVersion());
15var_dump(count($phar));
16
17class MyPhar extends Phar
18{
19    function __construct()
20    {
21    }
22}
23
24try
25{
26    $phar = new MyPhar();
27    var_dump($phar->getVersion());
28}
29catch (LogicException $e)
30{
31    var_dump($e->getMessage());
32}
33try {
34    $phar = new Phar('test.phar');
35    $phar->__construct('oops');
36} catch (LogicException $e)
37{
38    var_dump($e->getMessage());
39}
40
41?>
42--CLEAN--
43<?php
44unlink(__DIR__ . '/files/phar_oo_001.phar.php');
45__halt_compiler();
46?>
47--EXPECT--
48string(5) "1.0.0"
49int(5)
50string(50) "Cannot call method on an uninitialized Phar object"
51string(29) "Cannot call constructor twice"
52