public function setUp() { parent::setUp(); $this->plugin = $this->modx->newObject('modPlugin'); $this->plugin->fromArray(array('id' => 12345, 'name' => 'Unit Test Plugin', 'description' => 'A plugin for unit testing.', 'plugincode' => 'return "Hello.";', 'category' => 0, 'locked' => false, 'disabled' => false), '', true, true); $this->plugin->setProperties(array('name' => 'John')); $this->plugin->setCacheable(false); }
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ $plugins = []; $list = ['PageNotFoundSlackify' => ['description' => 'This plugin sends messages to defined channel in Slack when 404 error occurs on site.', 'events' => ['OnPageNotFound']], 'NewCommentTicketsSlackify' => ['description' => 'This plugin sends messages to defined channel in Slack when somebody added new comment to a ticket.', 'events' => ['OnCommentSave']], 'NewTicketTicketsSlackify' => ['description' => 'This plugin sends messages to defined channel in Slack when somebody created new ticket.', 'events' => ['OnDocFormSave']], 'ms2OrderStatusSlackify' => ['description' => 'This plugin sends messages to defined channel in Slack when order status was changed.', 'events' => ['msOnChangeOrderStatus']]]; foreach ($list as $k => $v) { $plugin = new modPlugin($xpdo); $plugin->fromArray(['id' => 0, 'name' => $k, 'category' => 0, 'description' => $v['description'], 'plugincode' => trim(str_replace(['<?php', '?>'], '', file_get_contents($sources['plugins'] . $k . '.php'))), 'static' => true, 'static_file' => 'core/components/' . PKG_NAME_LOWER . '/elements/plugins/' . $k . '.php', 'source' => 1, 'property_preprocess' => 0, 'editor_type' => 0, 'cache_type' => 0], '', true, true); if (!empty($v['events'])) { foreach ($v['events'] as $e) { $event = new modPluginEvent($xpdo); $event->fromArray(['pluginid' => 0, 'event' => $e, 'priority' => 0, 'propertyset' => 0], '', true, true); $plugin->addOne($event, 'PluginEvents'); } unset($v['events']); } $plugins[] = $plugin; } return $plugins;