ryxeo-glpi-git / htdocs / epack / lib / zip / testPclZipProxy.php @ 1c14bcc4
Historique | Voir | Annoter | Télécharger (4,77 ko)
1 | 1c14bcc4 | Eric Seigne | <?php
|
---|---|---|---|
2 | /**
|
||
3 | * Checking the PclZipProxy
|
||
4 | * PclZip library is required for this proxy
|
||
5 | * You need PHP 5.2 at least
|
||
6 | * You need Zip Extension or PclZip library
|
||
7 | * Encoding : ISO-8859-1
|
||
8 | * Last commit by $Author: neveldo $
|
||
9 | * Date - $Date: 2009-06-03 16:44:26 +0200 (mer., 03 juin 2009) $
|
||
10 | * SVN Revision - $Rev: 31 $
|
||
11 | * Id : $Id: odf.php 31 2009-06-03 14:44:26Z neveldo $
|
||
12 | *
|
||
13 | * @copyright GPL License 2008 - Julien Pauli - Cyril PIERRE de GEYER - Anaska (http://www.anaska.com)
|
||
14 | * @license http://www.gnu.org/copyleft/gpl.html GPL License
|
||
15 | * @version 1.3
|
||
16 | */
|
||
17 | require_once('PclZipProxy.php'); |
||
18 | $sep = PHP_EOL . '/****************************************/' . PHP_EOL; |
||
19 | chdir('../../tests/'); |
||
20 | copy('tutoriel1.odt', 'tmpTest.odt'); |
||
21 | |||
22 | echo 'Test 0 : constructeur de la classe '; |
||
23 | try {
|
||
24 | $zip = new PclZipProxy(); |
||
25 | echo '[ok] (objet créé)'; |
||
26 | } catch (Exception $e) { |
||
27 | echo '[erreur] ' . $e->getMessage(); |
||
28 | exit;
|
||
29 | } |
||
30 | echo $sep; |
||
31 | |||
32 | echo 'Test 1: $zip::getFromName(\'content.xml\') avec une archive non ouverte' . PHP_EOL; |
||
33 | $result1 = $zip->getFromName('content.xml'); |
||
34 | echo ($result1 === false) ? '[ok] (false)' : '[erreur] (true)'; |
||
35 | echo $sep; |
||
36 | |||
37 | echo 'Test 2: $zip::addFromString(\'content.xml\', \'test string\') avec une archive non ouverte' . PHP_EOL; |
||
38 | $result2 = $zip->addFromString('content.xml', 'test string'); |
||
39 | echo ($result2 === false) ? '[ok] (false)' : '[erreur] (true)'; |
||
40 | echo $sep; |
||
41 | |||
42 | echo 'Test 3: $zip::addFile(\'images/anaska.gif\', \'Pictures/anaska.gif\') avec une archive non ouverte' . PHP_EOL; |
||
43 | $result3 = $zip->addFile('images/anaska.gif', 'Pictures/anaska.gif'); |
||
44 | echo ($result3 === false) ? '[ok] (false)' : '[erreur] (true)'; |
||
45 | echo $sep; |
||
46 | |||
47 | echo 'Test 4: $zip::close() avec une archive non ouverte' . PHP_EOL; |
||
48 | $result4 = $zip->close(); |
||
49 | echo ($result4 === false) ? '[ok] (false)' : '[erreur] (true)'; |
||
50 | echo $sep; |
||
51 | |||
52 | echo 'Test 5: $zip::open(\'nothing.odt\') avec une archive inexistante (création de l\'archive)' . PHP_EOL; |
||
53 | $result5 = $zip->open('nothing.odt'); |
||
54 | echo ($result5 !== false) ? '[ok] (true)' : '[erreur] (false)'; |
||
55 | echo $sep; |
||
56 | |||
57 | echo 'Test 6: $zip::open() avec une archive existante' . PHP_EOL; |
||
58 | $result6 = $zip->open('tmpTest.odt'); |
||
59 | echo ($result6 !== false) ? '[ok] (true)' : '[erreur] (false)'; |
||
60 | echo $sep; |
||
61 | |||
62 | echo 'Test 7: $zip::getFromName(\'nothing.xml\') avec un fichier inexistant' . PHP_EOL; |
||
63 | $result7 = $zip->getFromName('nothing.xml'); |
||
64 | echo ($result7 === false) ? '[ok] (false)' : '[erreur] (true)'; |
||
65 | echo $sep; |
||
66 | |||
67 | echo 'Test 8: $zip::getFromName(\'content.xml\') avec un fichier existant' . PHP_EOL; |
||
68 | $result8 = $zip->getFromName('content.xml'); |
||
69 | echo ($result8 !== false) ? '[ok] ('.$result8.')' : '[erreur] (false)'; |
||
70 | echo $sep; |
||
71 | |||
72 | echo 'Test 9: $zip::addFromString(\'nothing.xml\', \'test string\') avec un fichier destination inexistant (création)' . PHP_EOL; |
||
73 | $result9 = $zip->addFromString('nothing.xml', 'test string'); |
||
74 | echo ($result9 !== false) ? '[ok] (true)' : '[erreur] (false)'; |
||
75 | echo $sep; |
||
76 | |||
77 | echo 'Test 10: $zip::addFromString(\'content.xml\', \'test string\') avec un fichier destination existant (remplacement)' . PHP_EOL; |
||
78 | $result10 = $zip->addFromString('content.xml', 'test string'); |
||
79 | echo ($result10 !== false) ? '[ok] (true)' : '[erreur] (false)'; |
||
80 | echo $sep; |
||
81 | |||
82 | echo 'Test 11: $zip::addFile(\'images/nothing.gif\', \'Pictures/anaska.gif\') avec un fichier source inexistant' . PHP_EOL; |
||
83 | $result11 = $zip->addFile('images/nothing.gif', 'Pictures/anaska.gif'); |
||
84 | echo ($result11 === false) ? '[ok] (false)' : '[erreur] (true)'; |
||
85 | echo $sep; |
||
86 | |||
87 | echo 'Test 12: $zip::addFile(\'images/anaska.gif\', \'Pictures/anaska.gif\') avec un fichier destination inexistant (création)' . PHP_EOL; |
||
88 | $result12 = $zip->addFile('images/anaska.gif', 'Pictures/anaska.gif'); |
||
89 | echo ($result12 !== false) ? '[ok] (true)' : '[erreur] (false)'; |
||
90 | echo $sep; |
||
91 | |||
92 | echo 'Test 13: $zip::addFile(\'images/anaska.gif\', \'Pictures/anaska.gif\') avec un fichier destination existant (remplacement)' . PHP_EOL; |
||
93 | $result13 = $zip->addFile('images/anaska.gif', 'Pictures/anaska.gif'); |
||
94 | echo ($result13 !== false) ? '[ok] (true)' : '[erreur] (false)'; |
||
95 | echo $sep; |
||
96 | |||
97 | echo 'Test 14: $zip::getFromName(\'nothingUHjiijI.xml\') avec un fichier inexistant' . PHP_EOL; |
||
98 | $result14 = $zip->getFromName('nothingUHjiijI.xml'); |
||
99 | echo ($result14 === false) ? '[ok] (false)' : '[erreur] (true)'; |
||
100 | echo $sep; |
||
101 | |||
102 | echo 'Test 15: $zip::getFromName(\'settings.xml\') avec un fichier existant' . PHP_EOL; |
||
103 | $result15 = $zip->getFromName('settings.xml'); |
||
104 | echo ($result15 !== false) ? '[ok] ('.$result15.')' : '[erreur] (false)'; |
||
105 | echo $sep; |
||
106 | |||
107 | echo 'Test 16: $zip::close() avec une archive ouverte' . PHP_EOL; |
||
108 | $result16 = $zip->close(); |
||
109 | echo ($result16 !== false) ? '[ok] (true)' : '[erreur] (false)'; |
||
110 | echo $sep; |
||
111 | unlink('tmpTest.odt'); |
||
112 | ?> |