Skip to content

Commit

Permalink
fix selenium tests to use a helper php file to get the current cypht …
Browse files Browse the repository at this point in the history
…configuration
  • Loading branch information
kroky committed Apr 30, 2024
1 parent ec5bdc1 commit 492f634
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
12 changes: 4 additions & 8 deletions tests/selenium/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as exp_cond
import glob
import subprocess
import json

class WebTest:

Expand All @@ -31,18 +33,12 @@ def __init__(self, cap=None):
def read_ini(self):
self.modules = []
self.auth_type = ''
# Assuming each PHP file returns an associative array
config_files = glob.glob('../../config/*.php')

for file_path in config_files:
# Create an empty dictionary to hold the variables from the included file
config_dict = {}
# Execute the PHP file in a new dictionary
exec(open(file_path).read(), config_dict)
# Check if 'modules' is in the dictionary and is a list
result = subprocess.run(['php', 'get_config.php'], stdout=subprocess.PIPE)
config_dict = json.loads(result.stdout.decode())
if 'modules' in config_dict and isinstance(config_dict['modules'], list):
self.modules += config_dict['modules']
# Check if 'auth_type' is in the dictionary
if 'auth_type' in config_dict:
self.auth_type = config_dict['auth_type']

Expand Down
7 changes: 7 additions & 0 deletions tests/selenium/get_config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

require '../../vendor/autoload.php';
require '../../lib/environment.php';
$config = merge_config_files('../../config');

echo json_encode($config);

0 comments on commit 492f634

Please sign in to comment.