Failed Conditions
Pull Request — experimental/sf (#3236)
by Kentaro
48:27
created

Acceptance   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 26
rs 10
c 0
b 0
f 0
wmc 6
lcom 0
cbo 1
1
<?php
2
namespace Helper;
3
// here you can define custom actions
4
// all public methods declared in helper class will be available in $I
5
6
class Acceptance extends \Codeception\Module
7
{
8
    public function _initialize()
9
    {
10
        $this->clearDownloadDir();
11
    }
12
13
    private function clearDownloadDir()
14
    {
15
        $downloadDir = dirname(__DIR__) . '/_downloads/';
16
        if (file_exists($downloadDir)) {
17
            $files = scandir($downloadDir);
18
            $files = array_filter($files, function ($fileName) use ($downloadDir) {
19
                return is_file($downloadDir.$fileName) && (strpos($fileName, '.') != 0);
20
            });
21
            foreach ($files as $f) {
22
                unlink($downloadDir.$f);
23
            }
24
        }
25
    }
26
27
    public function getBaseUrl()
28
    {
29
        return $this->getModule('WebDriver')->_getUrl();
30
    }
31
}
32