OSDN Git Service

This commit was generated by cvs2svn to compensate for changes in r4,
[nucleus-jp/nucleus-jp-ancient.git] / euc / build / testcases / NP_OptionTest.php
1 <?php\r
2 \r
3 /** \r
4   * Plugin for Nucleus CMS (http://plugins.nucleuscms.org/) \r
5   * Copyright (C) 2003-2004 The Nucleus Plugins Project\r
6   *\r
7   * This program is free software; you can redistribute it and/or\r
8   * modify it under the terms of the GNU General Public License\r
9   * as published by the Free Software Foundation; either version 2\r
10   * of the License, or (at your option) any later version.\r
11   *\r
12   * see license.txt for the full license\r
13   */\r
14 \r
15 class NP_OptionTest extends NucleusPlugin {\r
16 \r
17         // name of plugin\r
18         function getName() {\r
19                 return 'OptionTest'; \r
20         }\r
21         \r
22         // author of plugin\r
23         function getAuthor()  { \r
24                 return 'Wouter Demuynck'; \r
25         }\r
26         \r
27         // an URL to the plugin website\r
28         // can also be of the form mailto:foor@bar.com\r
29         function getURL() \r
30         {\r
31                 return 'http://nucleuscms.org/'; \r
32         }\r
33         \r
34         // version of the plugin\r
35         function getVersion() {\r
36                 return '1.0'; \r
37         }\r
38         \r
39         // a description to be shown on the installed plugins listing\r
40         function getDescription() { \r
41                 return 'Plugin to test blog and member options by plugins';\r
42         }\r
43         \r
44         function getMinNucleusVersion() {\r
45                 return 220;\r
46         }\r
47 \r
48         function install() {\r
49                 $aErrors = array();\r
50         \r
51                 echo '<h1>Creating some options</h1>';\r
52         \r
53                 if (!$this->createBlogOption('my option', 'my description', 'text', 'initial value', 'extra'))\r
54                         array_push($aErrors, 'create blog option failed');\r
55                         \r
56                 if (!$this->createBlogOption('my option2', 'my description2', 'yesno', 'no'))\r
57                         array_push($aErrors, 'create blog option 2 failed');\r
58                         \r
59                 if (!$this->createMemberOption('my option3', 'my description3', 'yesno', 'no'))\r
60                         array_push($aErrors, 'create member option failed');\r
61                         \r
62                 if (!$this->createCategoryOption('my option4', 'my description4', 'yesno', 'yes'))\r
63                         array_push($aErrors, 'create catgeory option failed');\r
64 \r
65                 echo '<h1>Creating some more options</h1>';\r
66                 // add some thingies with the same name\r
67                 $this->createCategoryOption('idem', 'idemd', 'text', 'category');\r
68                 $this->createOption('idem', 'idemd', 'text', 'global');\r
69                 $this->createBlogOption('idem', 'idemd', 'text', 'blog');\r
70                 $this->createMemberOption('idem', 'idemd', 'text', 'member');           \r
71                 \r
72                 echo '<h1>Checking options</h1>';               \r
73                 if ($this->getOption('idem') != 'global') \r
74                         array_push($aErrors, 'get should return "global" ' . $this->getOption('idem'));                 \r
75                 if ($this->getCategoryOption(1, 'idem') != 'category') \r
76                         array_push($aErrors, 'get should return "category" ' . $this->getCategoryOption(1, 'idem'));                    \r
77                 if ($this->getBlogOption(1, 'idem') != 'blog') \r
78                         array_push($aErrors, 'get should return "blog" ' . $this->getBlogOption(1, 'idem'));                    \r
79                 if ($this->getMemberOption(1, 'idem') != 'member') \r
80                         array_push($aErrors, 'get should return "member" ' . $this->getMemberOption(1, 'idem'));                        \r
81                         \r
82                 echo '<h1>Setting options</h1>';                        \r
83                 if (!$this->setOption('idem','edit-global'))\r
84                         array_push($aErrors, 'set option failed');\r
85                 if (!$this->setCategoryOption(1, 'idem', 'edit-category'))\r
86                         array_push($aErrors, 'set catgeory option failed');\r
87                 if (!$this->setBlogOption(1, 'idem', 'edit-blog'))\r
88                         array_push($aErrors, 'set blog option failed');\r
89                 if (!$this->setMemberOption(1, 'idem', 'edit-member'))\r
90                         array_push($aErrors, 'set member option failed');\r
91 \r
92                 echo '<h1>Checking options</h1>';\r
93                 if ($this->getOption('idem') != 'edit-global') \r
94                         array_push($aErrors, 'get should return "edit-global"');                        \r
95                 if ($this->getCategoryOption(1, 'idem') != 'edit-category') \r
96                         array_push($aErrors, 'get should return "edit-category"');                      \r
97                 if ($this->getBlogOption(1, 'idem') != 'edit-blog') \r
98                         array_push($aErrors, 'get should return "edit-blog"');                  \r
99                 if ($this->getMemberOption(1, 'idem') != 'edit-member') \r
100                         array_push($aErrors, 'get should return "edit-member"');                        \r
101                         \r
102                 if (count($aErrors) > 0);\r
103                         echo '<ul><li>' . implode('</li><li>', $aErrors). '</li></ul>';\r
104                 \r
105                 echo '<pre>';\r
106                 echo "All blog options:\n";\r
107                 print_r($this->getAllBlogOptions('idem'));\r
108                 \r
109                 echo "\nAll category options:\n";\r
110                 print_r($this->getAllCategoryOptions('idem'));\r
111 \r
112                 echo "\nAll member options:\n";\r
113                 print_r($this->getAllMemberOptions('idem'));\r
114 \r
115                 echo '</pre>';\r
116                 \r
117         }\r
118         \r
119 }\r
120 ?>