/** * check silverstripe db stub */ public function testRequireSilverstripeDB() { LivePubHelper::$init_code = array(); // check that nothing happens when not publishing LivePubHelper::require_silverstripe_db(); $this->assertEquals(count(LivePubHelper::$init_code), 0); // check that it does happen when publishing LivePubHelper::init_pub(); LivePubHelper::require_silverstripe_db(); $this->assertEquals(count(LivePubHelper::$init_code), 1); $this->assertEquals(preg_match('/\\$databaseConfig = array \\(.+\\);/ms', LivePubHelper::$init_code[0]), 1); // check that it's not included twice LivePubHelper::require_silverstripe_db(); $this->assertEquals(count(LivePubHelper::$init_code), 1); LivePubHelper::stop_pub(); }