Skip to content

Commit

Permalink
Adds missing function doc comments
Browse files Browse the repository at this point in the history
  • Loading branch information
kenorb committed Mar 26, 2018
1 parent 013081e commit 9c60c1a
Show file tree
Hide file tree
Showing 9 changed files with 174 additions and 30 deletions.
21 changes: 21 additions & 0 deletions src/NT/Drupal/Testing/Fixtures/fixture_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,29 @@ class fixture_helper {
protected static $instance;
protected $object_list = array();

/**
*
*/
protected function __construct() {}

/**
*
*/
protected function __clone() {}

/**
*
*/
public static function getInstance() {
if (!isset(self::$instance)) {
self::$instance = new fixture_helper();
}
return self::$instance;
}

/**
*
*/
public static function setup($fixture, $type = NULL) {
if (!empty($fixture)) {
$class = str_replace(' ', '_', strtolower($fixture));
Expand Down Expand Up @@ -48,6 +60,9 @@ public static function setup($fixture, $type = NULL) {
}
}

/**
*
*/
public static function clear($fixture = NULL) {
$helper = fixture_helper::getInstance();
if (isset($fixture)) {
Expand All @@ -56,10 +71,16 @@ public static function clear($fixture = NULL) {
$helper->remove_object($fixture);
}

/**
*
*/
public function add_object($obj) {
$this->object_list[] = $obj;
}

/**
*
*/
public function remove_object($fixture = NULL) {
foreach ($this->object_list as $key => $obj) {
if (isset($fixture)) {
Expand Down
38 changes: 37 additions & 1 deletion src/NT/Drupal/Testing/Fixtures/fixtures.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
*/
abstract class fixtures {

/**
*
*/
public function __construct() {
$data = $this->data();
$node = $this->parseData($data);
Expand Down Expand Up @@ -66,7 +69,7 @@ public function reset() {
/**
* Main function to create a fixture.
*
* @return Int
* @return int
* NID of the fixture created.
*/
public function run() {
Expand Down Expand Up @@ -104,6 +107,9 @@ protected function install_node($node) {
}
}

/**
*
*/
protected function dependanices(&$node) {
foreach ($node as $key => &$value) {
if ($key === 'nid' && is_object($value)) {
Expand All @@ -123,6 +129,9 @@ protected function dependanices(&$node) {
}
}

/**
*
*/
protected function multi_image($data) {
$output = array();
foreach ($data as $item) {
Expand All @@ -136,6 +145,9 @@ protected function multi_image($data) {
return $output;
}

/**
*
*/
protected function multi_nt_image($data) {
$output = array();
foreach ($data as $item) {
Expand All @@ -150,6 +162,9 @@ protected function multi_nt_image($data) {
return $output;
}

/**
*
*/
protected function install_image($data) {
$data += array(
'title' => 'image_' . time(),
Expand Down Expand Up @@ -195,6 +210,9 @@ protected function install_image($data) {
return $node;
}

/**
*
*/
protected function install_nt_image($data) {
$data += array(
'title' => 'image_' . time(),
Expand Down Expand Up @@ -242,6 +260,9 @@ protected function install_nt_image($data) {
return $node;
}

/**
*
*/
protected function install_rich_media($data) {
$data += array(
'title' => 'Rich Media_' . time(),
Expand Down Expand Up @@ -275,6 +296,9 @@ protected function install_rich_media($data) {
return $node;
}

/**
*
*/
protected function multi_media_ref($data) {
$output = array();
foreach ($data as $item) {
Expand All @@ -289,6 +313,9 @@ protected function multi_media_ref($data) {
return $output;
}

/**
*
*/
protected function install_media_ref($data) {
$type = array_shift(array_keys($data));
$id = NULL;
Expand All @@ -309,6 +336,9 @@ protected function install_media_ref($data) {
return $id;
}

/**
*
*/
protected function multi_video($data) {
$output = array();
foreach ($data as $item) {
Expand All @@ -323,6 +353,9 @@ protected function multi_video($data) {
return $output;
}

/**
*
*/
protected function install_video($data) {
$data += array(
'title' => 'Video_' . time(),
Expand Down Expand Up @@ -387,6 +420,9 @@ protected function install_video($data) {
return $node;
}

/**
*
*/
protected function install_nt_video($data) {
$data += array(
'title' => 'Video_' . time(),
Expand Down
35 changes: 25 additions & 10 deletions src/NT/Drupal/Testing/PHPUnit/drupal_test_case.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,9 @@ abstract class DrupalTestCase extends TestCase {
*/
protected $redirect_count;

/**
*
*/
public function run(TestResult $result = NULL) {
$this->setPreserveGlobalState(FALSE);
return parent::run($result);
Expand Down Expand Up @@ -200,10 +203,16 @@ protected function error($message = '', $group = 'Other', array $caller = NULL)
return $this->fail('exception: ' . $message, $group);
}

/**
*
*/
public function assertEqual($expected, $actual, $msg = NULL) {
return $this->assertEquals($expected, $actual, $msg);
}

/**
*
*/
public function assertIdentical($first, $second, $message = '', $group = 'Other') {
return $this->assertSame($first, $second, $message);
}
Expand Down Expand Up @@ -1120,6 +1129,9 @@ public static function generatePermutations($parameters) {
return $all_permutations;
}

/**
*
*/
public function verbose($message) {
}

Expand Down Expand Up @@ -1352,7 +1364,7 @@ protected function curlExec($curl_options, $redirect = FALSE) {
/**
* Reads headers and registers errors received from the tested site.
*
* @see _drupal_log_error().
* @see _drupal_log_error()
*
* @param $curlHandler
* The cURL handler.
Expand Down Expand Up @@ -1665,7 +1677,7 @@ protected function drupalLogin(stdClass $user) {
}
}

/*
/**
* Logs a user out of the internal browser, then check the login page to confirm logout.
*/
protected function drupalLogout() {
Expand Down Expand Up @@ -2354,14 +2366,11 @@ protected function drupalSetSettings($settings) {
}

/*
*Print a log message to the console.
* Print a log message to the console.
*
* @param string $message
* @param string $type
* Supported types are:
* - notice
* - verbose
* - debug
* Supported types are: notice, verbose, debug.
*/
public function log($message, $type = 'notice') {
$line = "\nLog: $message\n";
Expand All @@ -2378,7 +2387,10 @@ public function log($message, $type = 'notice') {
}
}

public function log_level() {
/**
*
*/
public function log_level() {
if (in_array('--debug', $_SERVER['argv'])) {
return 'debug';
}
Expand All @@ -2387,6 +2399,9 @@ public function log_level() {
}
}

/**
*
*/
public function directory_cache($subdir = '') {
return getenv('CACHE_PREFIX') . '/' . $subdir;
}
Expand Down Expand Up @@ -2414,9 +2429,9 @@ public static function drop_tables($database) {
/**
* Import database dump to be used.
*
* @param String $database
* @param string $database
* Database name to be used.
* @param String $file
* @param string $file
* The dump file to import.
*/
public static function import_database($database, $file) {
Expand Down
6 changes: 6 additions & 0 deletions src/NT/Drupal/Testing/PHPUnit/drupal_unit_test_case.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ abstract class DrupalUnitTestCase extends DrupalTestCase {
/* @var int Current drupal run time level */
protected $drupal_level;

/**
*
*/
public function setUp($bootstrap = DRUPAL_BOOTSTRAP_FULL, $file = UPAL_USE_DB) {
parent::setUp();
$this->drupal_level = $bootstrap;
Expand All @@ -33,6 +36,9 @@ public function setUp($bootstrap = DRUPAL_BOOTSTRAP_FULL, $file = UPAL_USE_DB) {
drupal_bootstrap($bootstrap);
}

/**
*
*/
protected function tearDown() {
parent::tearDown();
DrupalTestCase::drop_tables(DB_DB);
Expand Down
14 changes: 13 additions & 1 deletion src/NT/Drupal/Testing/PHPUnit/drupal_web_test_case.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@
namespace NT\Drupal\Testing\PHPUnit;

/**
*
* Implements DrupalWebTestCase abstract class.
*/
abstract class DrupalWebTestCase extends DrupalTestCase {

protected $prefix;

/**
*
*/
public function setUp() {
parent::setUp();

Expand Down Expand Up @@ -124,6 +127,9 @@ public function setUp() {
variable_set('file_public_path', 'sites/upal/files');
}

/**
*
*/
protected function tearDown() {
parent::tearDown();
$time = time();
Expand All @@ -140,6 +146,9 @@ protected function tearDown() {
fixture_helper::clear();
}

/**
*
*/
public function runCron() {
$cmd = sprintf(
'%s cron --root=%s --uri=%s',
Expand All @@ -150,6 +159,9 @@ public function runCron() {
exec($cmd, $output, $return);
}

/**
*
*/
public function dropCache() {
$cmd = sprintf(
'%s cache-clear all --root=%s --uri=%s',
Expand Down
Loading

0 comments on commit 9c60c1a

Please sign in to comment.