public function test_require_with_args() { $fileToInclude = $this->__dirInputs . DIRECTORY_SEPARATOR . 'test_require_with_args.php'; $result = UtilCode::require_with_args($fileToInclude, ['parameter' => 15]); $this->assertTrue(is_array($result)); $this->assertCount(1, $result); $this->assertEquals(30, $result[0]); }
/** * Create the MSql database. * Please call __init() and __createMySqlPdo() first. */ private function __createMySqlDatabase() { // ------------------------------------------------------------------------------------------------------------- // Load the configuration and open a connection to the database. // ------------------------------------------------------------------------------------------------------------- $schema = (require $this->__generalConfiguration['test']['dir.fixtures'] . DIRECTORY_SEPARATOR . 'MySql' . DIRECTORY_SEPARATOR . 'schema.php'); // ------------------------------------------------------------------------------------------------------------- // Drop the database, then re-create. // ------------------------------------------------------------------------------------------------------------- foreach ($schema as $_request) { $req = $this->__mySqlPdo->prepare($_request); if (false === $req->execute([])) { throw new \Exception("Can not create the database."); } } // ------------------------------------------------------------------------------------------------------------- // Load data into the database. // ------------------------------------------------------------------------------------------------------------- $dataPath = $this->__generalConfiguration['test']['dir.fixtures'] . DIRECTORY_SEPARATOR . 'MySql' . DIRECTORY_SEPARATOR . 'data.php'; \dbeurive\Util\UtilCode::require_with_args($dataPath, ['pdo' => $this->__mySqlPdo]); }