Skip to content

Commit

Permalink
[Core] Fix errors related to undefined classes detected by phan (#3637)
Browse files Browse the repository at this point in the history
Fix undefined class errors detected by phan. This necessitated
adding the test directory to analysis, which also required fixing
some other errors in the test directory. (Otherwise, "LorisIntegrationTest"
and family were detected as undefined classes.)
  • Loading branch information
driusan authored May 7, 2018
1 parent 9560d51 commit 9cefbcd
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 66 deletions.
8 changes: 6 additions & 2 deletions .phan/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@
"PhanUndeclaredClassMethod",
"PhanUndeclaredTypeParameter",
"PhanUndeclaredConstant",
"PhanUndeclaredClass",
"PhanUndeclaredExtendedClass",
"PhanTypeMismatchForeach",
"PhanTypeMismatchDefault",
"PhanTypeMismatchArgument",
Expand Down Expand Up @@ -58,8 +56,14 @@
"modules",
"src",
"vendor",
"test"
],
"exclude_analysis_directory_list" => [
"vendor",
],
'autoload_internal_extension_signatures' => [
// Xdebug stubs are bundled with Phan 0.10.1+/0.8.9+ for usage,
// because Phan disables xdebug by default.
'xdebug' => 'vendor/phan/phan/.phan/internal_stubs/xdebug.phan_php',
],
];
28 changes: 0 additions & 28 deletions php/libraries/LorisApp.class.inc

This file was deleted.

32 changes: 16 additions & 16 deletions test/integrationtests/LorisIntegrationTest.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ abstract class LorisIntegrationTest extends TestCase
* instantiting the config and database objects, creating a user
* to user for the tests, and logging in.
*
* @return none
* @return void
*/
public function setUp()
{
Expand Down Expand Up @@ -111,7 +111,7 @@ abstract class LorisIntegrationTest extends TestCase

$this->login("UnitTester", "4test4");

if (extension_loaded('xdebug')) {
if (extension_loaded('xdebug') && function_exists("xdebug_start_code_coverage")) {
xdebug_start_code_coverage(XDEBUG_CC_UNUSED | XDEBUG_CC_DEAD_CODE);
}

Expand All @@ -124,7 +124,7 @@ abstract class LorisIntegrationTest extends TestCase
* @param string $username The username to log in as
* @param string $password The (plain text) password to login as.
*
* @return none, side-effect logs in active webDriver
* @return void but side-effect logs in active webDriver
*/
protected function login($username, $password)
{
Expand Down Expand Up @@ -160,7 +160,7 @@ abstract class LorisIntegrationTest extends TestCase
* its permissions. user_login_history also must be purged as it contains a
* foreign key to users
*
* @return none
* @return void
*/
public function tearDown()
{
Expand Down Expand Up @@ -190,7 +190,7 @@ abstract class LorisIntegrationTest extends TestCase
*
* @throws LorisException
*
* @return none
* @return void
*/
function setupConfigSetting($configName, $value)
{
Expand Down Expand Up @@ -235,7 +235,7 @@ abstract class LorisIntegrationTest extends TestCase
*
* @throws LorisException
*
* @return none
* @return void
*/
function restoreConfigSetting($configName)
{
Expand All @@ -260,7 +260,7 @@ abstract class LorisIntegrationTest extends TestCase
*
* @param array $permissions List of permissions codes to add TestUser
*
* @return none
* @return void
*/
function setupPermissions($permissions)
{
Expand All @@ -284,7 +284,7 @@ abstract class LorisIntegrationTest extends TestCase
* Helper function to reset user permissions. The function works by adding
* all permissions to the TestUser.
*
* @return none
* @return void
*/
function resetPermissions()
{
Expand All @@ -296,7 +296,7 @@ abstract class LorisIntegrationTest extends TestCase
/**
* Helper function to change the users Study Site
*
* @return none
* @return void
*/
function changeStudySite()
{
Expand All @@ -307,7 +307,7 @@ abstract class LorisIntegrationTest extends TestCase
/**
* Helper function to reset the users Study Site
*
* @return none
* @return void
*/
function resetStudySite()
{
Expand All @@ -320,7 +320,7 @@ abstract class LorisIntegrationTest extends TestCase
*
* @param string $title Name of the subproject
*
* @return none
* @return void
*/
function createSubproject($SubprojectID,$title)
{
Expand All @@ -340,7 +340,7 @@ abstract class LorisIntegrationTest extends TestCase
*
* @param string $title Name of the subproject
*
* @return none
* @return void
*/
function deleteSubproject($title)
{
Expand Down Expand Up @@ -390,7 +390,7 @@ abstract class LorisIntegrationTest extends TestCase
*
* @param string $pscid The PSCID of teh candiate to delete
*
* @return none
* @return void
*/
function deleteCandidate($pscid)
{
Expand Down Expand Up @@ -502,12 +502,12 @@ abstract class LorisIntegrationTest extends TestCase
* @throws ElementNotVisibleException if $allowJavascriptClick is false and the
* element cannot be clicked on because it is
* not visible.
* @throws StaleElementReferenceExceptoin if $allowJavascriptClick is false and
* @throws StaleElementReferenceException if $allowJavascriptClick is false and
* the element cannot be clicked on
* because the DOM was updated since the
* element was found.
*
* @return void.
* @return void
*/
function safeClick(WebDriverBy $by, $waitPeriod=15, $allowJavascriptClick=true)
{
Expand All @@ -518,7 +518,7 @@ abstract class LorisIntegrationTest extends TestCase
$clickException = null;
} catch(ElementNotVisibleException $e) {
$clickException = $e;
} catch(StaleElementReferenceExceptoin $e) {
} catch(StaleElementReferenceException $e) {
$clickException = $e;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ abstract class LorisIntegrationTestWithCandidate extends LorisIntegrationTest
* to user for the tests, and logging in, and creating a candidate
* with a session
*
* @return none
* @return void
*/
public function setUp()
{
Expand Down
28 changes: 14 additions & 14 deletions test/unittests/LorisForms_Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class LorisForms_Test extends TestCase
/**
* Creates a new LorisForm to use for testing
*
* @return none
* @return void
*/
function setUp()
{
Expand All @@ -45,7 +45,7 @@ function setUp()
* @param string $type The expected type of this element
* (ie select, checkbox, etc)
*
* @return none, but makes assertions
* @return void but makes assertions
*/
function assertType($el, $type)
{
Expand All @@ -68,7 +68,7 @@ function assertType($el, $type)
* @param string $label The expected type of this element
* (ie select, checkbox, etc)
*
* @return none, but makes assertions
* @return void but makes assertions
*/
function assertLabel($el, $label)
{
Expand All @@ -88,7 +88,7 @@ function assertLabel($el, $label)
* Test that the addSelect wrapper adds an element of the appropriate
* type to the page
*
* @return none
* @return void
*/
function testAddSelect()
{
Expand All @@ -103,7 +103,7 @@ function testAddSelect()
* Test that the addSelect wrapper adds an element of the appropriate
* type to the page
*
* @return none
* @return void
*/
function testAddMultiSelect()
{
Expand Down Expand Up @@ -131,7 +131,7 @@ function testAddMultiSelect()
* Test that the addText wrapper adds an element of the appropriate
* type to the page
*
* @return none
* @return void
*/
function testAddText()
{
Expand All @@ -144,7 +144,7 @@ function testAddText()
* Test that the addDate wrapper adds an element of the appropriate
* type to the page
*
* @return none
* @return void
*/
function testAddDate()
{
Expand All @@ -158,7 +158,7 @@ function testAddDate()
* Test that the addDate wrapper adds an element of the appropriate
* type to the page
*
* @return none
* @return void
*/
function testAddFile()
{
Expand All @@ -172,7 +172,7 @@ function testAddFile()
* Test that the addDate wrapper adds an element of the appropriate
* type to the page
*
* @return none
* @return void
*/
function testAddPassword()
{
Expand All @@ -186,7 +186,7 @@ function testAddPassword()
* Test that the addElement wrapper with type "select" adds an element of
* the appropriate type to the page
*
* @return none
* @return void
*/
function testAddElementSelect()
{
Expand All @@ -202,7 +202,7 @@ function testAddElementSelect()
* Test that the addElement wrapper with type "date" adds an element of
* the appropriate type to the page
*
* @return none
* @return void
*/
function testAddElementDate()
{
Expand All @@ -218,7 +218,7 @@ function testAddElementDate()
* Test that the addElement wrapper with type "text" adds an element of
* the appropriate type to the page
*
* @return none
* @return void
*/
function testAddElementText()
{
Expand All @@ -234,7 +234,7 @@ function testAddElementText()
* Test that the addElement wrapper with type "text" adds an element of
* the appropriate type to the page
*
* @return none
* @return void
*/
function testAddElementFile()
{
Expand All @@ -250,7 +250,7 @@ function testAddElementFile()
* Test that the addElement wrapper with type "password" adds an element of
* the appropriate type to the page
*
* @return none
* @return void
*/
function testAddElementPassword()
{
Expand Down
4 changes: 2 additions & 2 deletions test/unittests/Loris_PHPUnit_Database_TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ abstract class Loris_PHPUnit_Database_TestCase extends TestCase
*
* Only instantiate _pdo once for test clean-up/fixture load
*
* @var PDO
* @var \PDO
*/
static private $_pdo = null;

/**
* Note: only instantiate PHPUnit_Extensions_Database_DB_IDatabaseConnection
* once per test
*
* @var PHPUnit_Extensions_Database_DB_IDatabaseConnection
* @var \PHPUnit\DbUnit\Database\Connection
*/
private $_conn = null;

Expand Down
2 changes: 1 addition & 1 deletion test/unittests/NDB_BVL_FeedbackTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ protected function setUp()
* Returns test data set.
* Populates table feedback_bvl_type.
*
* @return PHPUnit_Extensions_Database_DataSet_IDataSet
* @return \PHPUnit\DbUnit\DataSet\IDataSet
*/
protected function getDataSet()
{
Expand Down
2 changes: 1 addition & 1 deletion test/unittests/NDB_BVL_Instrument_LINST_ToJSON_Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function setUp() {
define("UNIT_TESTING", true);
}
date_default_timezone_set("UTC");
$this->Session = $this->getMockBuilder(stdClass::class)->setMethods(array('getProperty', 'setProperty', 'getUsername', 'isLoggedIn'))->getMock();
$this->Session = $this->getMockBuilder(\stdClass::class)->setMethods(array('getProperty', 'setProperty', 'getUsername', 'isLoggedIn'))->getMock();
$this->MockSinglePointLogin = $this->getMockBuilder('SinglePointLogin')->getMock();
$this->Session->method("getProperty")->willReturn($this->MockSinglePointLogin);

Expand Down
2 changes: 1 addition & 1 deletion test/unittests/NDB_BVL_Instrument_ToJSON_Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function setUp() {
define("UNIT_TESTING", true);
}
date_default_timezone_set("UTC");
$this->Session = $this->getMockBuilder(stdClass::class)->setMethods(array('getProperty', 'setProperty', 'getUsername', 'isLoggedIn'))->getMock();
$this->Session = $this->getMockBuilder(\stdClass::class)->setMethods(array('getProperty', 'setProperty', 'getUsername', 'isLoggedIn'))->getMock();
$this->MockSinglePointLogin = $this->getMockBuilder('SinglePointLogin')->getMock();
$this->Session->method("getProperty")->willReturn($this->MockSinglePointLogin);

Expand Down
1 change: 1 addition & 0 deletions test/unittests/api/v0.0.1/NDB_BVL_Instrument_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ function __construct() {
}

function save() {
return true;
}

function _hasAccess() {
Expand Down

0 comments on commit 9cefbcd

Please sign in to comment.