Skip to content

Instantly share code, notes, and snippets.

@nullvariable
Last active April 21, 2016 15:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nullvariable/f26495522e481d2c8225f3f610a3d605 to your computer and use it in GitHub Desktop.
Save nullvariable/f26495522e481d2c8225f3f610a3d605 to your computer and use it in GitHub Desktop.
Mocking a Drupal 7 core function with namespaces
<?php
namespace Same\As\Class\Testing
{
function drupal_valid_token($token = NULL)
{
return ($token == "expected value);
}
class moduleNameTestSuite extendsDrupalWebTestCase
{
//static public function getInfo() ...
public function setUp()
{
parent::setUp(array('moduleName'));
}
public function testValidate()
{
$testData = array(/*...*/);
$object = new moduleNameClass($testData);
$this->assertEqual($object->key, $testData['key'];
}
}
}
namespace
{
moduleNameGlobalTest extends \Same\As\Class\Testing\moduleNameTestSuite
{
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment