Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
UrlAnalyzer.php
Go to the documentation of this file.
1 <?php
8 
13 {
20  public function fixLastSlash($key)
21  {
22  $message = [];
23  $param = sprintf('%s" value="%s', $key, $_ENV[$key]);
24  $fileContents = file_get_contents(MTF_PHPUNIT_FILE);
25  $lastSymbol = substr($param, -1);
26  if ($lastSymbol != '/') {
27  $_ENV[$key] = $_ENV[$key] . '/';
28  $fileContents = str_replace($param, $param . '/', $fileContents);
29  file_put_contents(MTF_PHPUNIT_FILE, $fileContents);
30  $message['info'][] = "Slash at the end of url was added in the config file.";
31  }
32  return $message;
33  }
34 
41  public function resolveIndexPhpProblem($url)
42  {
43  $fileContents = file_get_contents(MTF_PHPUNIT_FILE);
44  $pattern = '/(backend_url.*?=")(.+)"/';
45  $replacement = "$1{$url}\"";
46  $fileContents = preg_replace($pattern, $replacement, $fileContents);
47  file_put_contents(MTF_PHPUNIT_FILE, $fileContents);
48  return ['info' => ['"app_backend_url" has been updated in the phpunit.xml.']];
49  }
50 
57  public function checkDomain($url)
58  {
59  $messages = [];
60  $pattern = '/([-%\w]*?\.\w+)/';
61  if (preg_match($pattern, $url) === false) {
62  $messages['error'][] =
63  'Instance should have domain name with at least one subdomain to function correctly. Examples:'
64  . PHP_EOL . "\tValid: http://magento.dev/, https://mage.local/."
65  . PHP_EOL . "\tInvalid: http://localhost/, https://magento/.";
66  }
67 
68  return $messages;
69  }
70 }
$pattern
Definition: website.php:22
$message
$replacement
Definition: website.php:23