not->toBeFalse(); $start = strpos($source, 'function ldap_convert_1_3_0() : void {'); expect($start)->not->toBeFalse(); $end = strpos($source, "\n}\n", (int) $start); expect($end)->not->toBeFalse(); $body = substr($source, (int) $start, (int) $end - (int) $start); $guard = strpos($body, "!db_table_exists('user_domains_ldap')"); $return = strpos($body, 'return;'); $firstSql = strpos($body, 'db_install_execute('); expect($guard)->not->toBeFalse(); expect($return)->not->toBeFalse(); expect($firstSql)->not->toBeFalse(); // The existence guard and its early return must precede every ALTER. expect($guard)->toBeLessThan($return); expect($return)->toBeLessThan($firstSql); }); test('the legacy user_domains column migrations are gated on the table existing', function () use ($upgrade) { $source = file_get_contents($upgrade); expect($source)->not->toBeFalse(); expect($source) ->toContain("if (db_table_exists('user_domains') && !db_column_exists('user_domains', 'debug'))") ->toContain("if (db_table_exists('user_domains_ldap') && !db_column_exists('user_domains_ldap', 'network_timeout'))") ->toContain("if (db_table_exists('user_domains_ldap') && !db_column_exists('user_domains_ldap', 'bind_timeout'))"); // The pre-fix unguarded form against the legacy tables must never return. expect($source) ->not->toContain("if (!db_column_exists('user_domains',") ->not->toContain("if (!db_column_exists('user_domains_ldap',"); });