File: XDebugTester.cpp

package info (click to toggle)
codelite 14.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 112,816 kB
  • sloc: cpp: 483,662; ansic: 150,144; php: 9,569; lex: 4,186; python: 3,417; yacc: 2,820; sh: 1,147; makefile: 52; xml: 13
file content (108 lines) | stat: -rw-r--r-- 5,028 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#include "XDebugTester.h"
#include "cl_standard_paths.h"
#include <wx/filename.h>
#include "clZipReader.h"
#include "phpexecutor.h"
#include <wx/msgdlg.h>
#include "JSON.h"
#include "php_configuration_data.h"

XDebugTester::XDebugTester() {}

XDebugTester::~XDebugTester() {}

bool XDebugTester::RunTest()
{
    // Get the path to the xdebug tester script
    wxFileName xdebugTesterScript(clStandardPaths::Get().GetUserDataDir(), "TestXDebugSettings.php");
    if(!xdebugTesterScript.Exists()) {
        clZipReader zipReader(wxFileName(clStandardPaths::Get().GetDataDir(), "PHP.zip"));
        zipReader.Extract(xdebugTesterScript.GetFullName(), xdebugTesterScript.GetPath());
    }

    if(xdebugTesterScript.Exists()) {
        PHPConfigurationData globalConf;
        globalConf.Load();

        PHPExecutor executor;
        wxString php_output;
        if(executor.RunScript(xdebugTesterScript.GetFullPath(), php_output)) {
            JSON root(php_output);
            JSONItem rootElement = root.toElement();

            //////////////////////////////////////////////////
            // Directives
            //////////////////////////////////////////////////
            {
                wxString msg;
                if(rootElement.namedObject("_remoteConnectBack").toString() != "1") {
                    msg << "<font color=\"red\">Failed. This value should be set to 1</font>";
                } else {
                    msg << "<font color=\"green\">Passed</font>";
                }
                m_results.insert(
                    std::make_pair(wxString("xdebug.remote_connect_back"),
                                   std::make_pair(rootElement.namedObject("_remoteConnectBack").toString(), msg)));
            }
            {
                wxString msg;
                if(rootElement.namedObject("_ideKey").toString() != globalConf.GetXdebugIdeKey()) {
                    msg << "<font color=\"red\">Failed. This value should be set to \"" << globalConf.GetXdebugIdeKey()
                        << "\"</font>";
                } else {
                    msg << "<font color=\"green\">Passed</font>";
                }
                m_results.insert(std::make_pair(wxString("xdebug.idekey"),
                                                std::make_pair(rootElement.namedObject("_ideKey").toString(), msg)));
            }
            m_results.insert(std::make_pair(
                wxString("xdebug.remote_port"),
                std::make_pair(rootElement.namedObject("_remotePort").toString(),
                               "The port to which Xdebug tries to connect on the remote host. The default is 9000")));

            m_results.insert(std::make_pair(wxString("xdebug.remote_host"),
                                            std::make_pair(rootElement.namedObject("_remoteHost").toString(),
                                                           "Selects the host where the debug client is running\nYou "
                                                           "can either use a host name or an IP address.\nThis setting "
                                                           "is ignored if xdebug.remote_connect_back is enabled")));
            {
                wxString msg;
                if(rootElement.namedObject("_remoteEnable").toString() != "1") {
                    msg << "<font color=\"red\">Failed. This value should be set to 1</font>";
                } else {
                    msg << "<font color=\"green\">Passed</font>";
                }
                m_results.insert(
                    std::make_pair(wxString("xdebug.remote_enable"),
                                   std::make_pair(rootElement.namedObject("_remoteEnable").toString(), msg)));
            }
            {
                // XDebug loaded
                wxString msg;
                if(rootElement.namedObject("_xdebugLoaded").toString() != "1") {
                    msg << "<font color=\"red\">Failed. XDebug is NOT loaded</font>";
                } else {
                    msg << "<font color=\"green\">Passed</font>";
                }
                m_results.insert(
                    std::make_pair(wxString("XDebug Loaded"),
                                   std::make_pair(rootElement.namedObject("_xdebugLoaded").toString(), msg)));
            }

            // Zend Debugger loaded
            {
                // If Zend Debugger is loaded, mark it the message with RED
                wxString msg;
                if(rootElement.namedObject("_zendDebuggerLoaded").toString() == "1") {
                    msg << "<font color=\"red\">Failed. Unload Zend Debugger extension"
                           "</font>";
                    m_results.insert(
                        std::make_pair(wxString("Zend Debugger Loaded"),
                                       std::make_pair(rootElement.namedObject("_zendDebuggerLoaded").toString(), msg)));
                }
            }
            return true;
        }
    }
    return false;
}