- <?php
- * @file
- * Hook implementations for the SimpleTest Example module.
- */
-
- * @defgroup simpletest_example Example: Simpletest
- * @ingroup examples
- * @{
- * This example demonstrates how to implement simpletest tests.
- *
- * This module creates a new "SimpleTest Example Node Type" content type we can
- * test.
- *
- * See also
- * @link https://docs.backdropcms.org/documentation/testing-framework Testing Framework @endlink.
- */
-
- * Implements hook_permission().
- *
- * In this case we're adding an additional permission that does the same as the
- * one the node module offers, just to demonstrate this error.
- */
- function simpletest_example_permission() {
- $perms = array();
- $perms['extra special edit any simpletest_example'] = array('title' => t('Extra special edit any SimpleTest Example'), 'description' => t('Extra special edit any SimpleTest Example'));
- return $perms;
- }
-
- * Implements hook_node_access().
- *
- * Demonstrates a bug that we'll find in our test.
- *
- * If this is running on the testbot, we don't want the error to show so will
- * work around it by testing to see if we're in the 'checkout' directory.
- */
- function simpletest_example_node_access($node, $op, $account) {
-
- $type = is_string($node) ? $node : $node->type;
- if ($type != 'simpletest_example' || ($op != 'update' && $op != 'delete')) {
- return NODE_ACCESS_IGNORE;
- }
-
-
-
-
-
-
-
- if (($op == 'delete') && (user_access('extra special edit any simpletest_example', $account) && ($account->uid == $node->uid))) {
- return NODE_ACCESS_ALLOW;
- }
-
- return NODE_ACCESS_DENY;
- }
-
- * Implements hook_form().
- *
- * Form for the node type.
- */
- function simpletest_example_form($node, $form_state) {
- $type = node_type_get_type($node);
- $form = array();
- if ($type->has_title) {
- $form['title'] = array(
- '#type' => 'textfield',
- '#title' => check_plain($type->title_label),
- '#required' => TRUE,
- '#default_value' => $node->title,
- '#maxlength' => 255,
- '#weight' => -5,
- );
- }
- return $form;
- }
-
- * Implements hook_menu().
- *
- * Provides an explanation.
- */
- function simpletest_example_menu() {
- $items['examples/simpletest_example'] = array(
- 'title' => 'Simpletest Example',
- 'description' => 'Explain the simpletest example and allow the error logic to be executed.',
- 'page callback' => '_simpletest_example_explanation',
- 'access callback' => TRUE,
- );
- return $items;
- }
-
- * Returns an explanation of this module.
- */
- function _simpletest_example_explanation() {
- return t('This Simpletest Example is designed to give an example of simpletest tests to accompany <a href="@testing_framework">Testing Framework</a>.',
- array('@testing_framework' => 'https://docs.backdropcms.org/documentation/testing-framework')
- );
- }
-
- * A simple self-contained function used to demonstrate unit tests.
- *
- * @see SimpletestUnitTestExampleTestCase
- */
- function simpletest_example_empty_mysql_date($date_string) {
- if (empty($date_string) || $date_string == '0000-00-00' || $date_string == '0000-00-00 00:00:00') {
- return TRUE;
- }
- return FALSE;
- }
-
- * @} End of "defgroup simpletest_example".
- */