Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
MftfApplicationConfig.php
Go to the documentation of this file.
1 <?php
7 
9 
11 {
12  const GENERATION_PHASE = "generation";
13  const EXECUTION_PHASE = "execution";
14  const UNIT_TEST_PHASE = "testing";
16 
22  private $forceGenerate;
23 
29  private $phase;
30 
36  private $verboseEnabled;
37 
43  private $debugEnabled;
44 
50  private static $MFTF_APPLICATION_CONTEXT;
51 
61  private function __construct(
62  $forceGenerate = false,
63  $phase = self::EXECUTION_PHASE,
64  $verboseEnabled = null,
65  $debugEnabled = null
66  ) {
67  $this->forceGenerate = $forceGenerate;
68 
69  if (!in_array($phase, self::MFTF_PHASES)) {
70  throw new TestFrameworkException("{$phase} is not an mftf phase");
71  }
72 
73  $this->phase = $phase;
74  $this->verboseEnabled = $verboseEnabled;
75  $this->debugEnabled = $debugEnabled;
76  }
77 
88  public static function create($forceGenerate, $phase, $verboseEnabled, $debugEnabled)
89  {
90  if (self::$MFTF_APPLICATION_CONTEXT == null) {
91  self::$MFTF_APPLICATION_CONTEXT =
92  new MftfApplicationConfig($forceGenerate, $phase, $verboseEnabled, $debugEnabled);
93  }
94  }
95 
101  public static function getConfig()
102  {
103  // TODO explicitly set this with AcceptanceTester or MagentoWebDriver
104  // during execution we cannot guarantee the use of the robofile so we return the default application config,
105  // we don't want to set the application context in case the user explicitly does so at a later time.
106  if (self::$MFTF_APPLICATION_CONTEXT == null) {
107  return new MftfApplicationConfig();
108  }
109 
110  return self::$MFTF_APPLICATION_CONTEXT;
111  }
112 
118  public function forceGenerateEnabled()
119  {
120  return $this->forceGenerate;
121  }
122 
129  public function verboseEnabled()
130  {
131  return $this->verboseEnabled ?? getenv('MFTF_DEBUG');
132  }
133 
140  public function debugEnabled()
141  {
142  return $this->debugEnabled ?? getenv('MFTF_DEBUG');
143  }
144 
150  public function getPhase()
151  {
152  return $this->phase;
153  }
154 }
static create($forceGenerate, $phase, $verboseEnabled, $debugEnabled)