コード例 #1
0
ファイル: UtilCodeTest.php プロジェクト: dbeurive/util
 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]);
 }
コード例 #2
0
ファイル: SetUp.php プロジェクト: dbeurive/backend
 /**
  * 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]);
 }