1 | <?php |
||
13 | class Local implements ImageDriverInterface |
||
14 | { |
||
15 | const DEFAULT_DIRECTORY = 'behat-screenshot'; |
||
16 | const CONFIG_PARAM_SCREENSHOT_DIRECTORY = 'screenshot_directory'; |
||
17 | const CONFIG_PARAM_CLEAR_SCREENSHOT_DIRECTORY = 'clear_screenshot_directory'; |
||
18 | const ERROR_MESSAGE_FINFO_NOT_FOUND = 'The fileinfo PHP extension is required, but not installed.'; |
||
19 | |||
20 | /** |
||
21 | * @var Filesystem |
||
22 | */ |
||
23 | private $filesystem; |
||
24 | |||
25 | /** |
||
26 | * @var string |
||
27 | */ |
||
28 | private $screenshotDirectory; |
||
29 | |||
30 | /** |
||
31 | * @var Finder |
||
32 | */ |
||
33 | private $finder; |
||
34 | |||
35 | /** |
||
36 | * @var \finfo |
||
37 | */ |
||
38 | private $fileInfo; |
||
39 | |||
40 | /** |
||
41 | * @param Filesystem $filesystem |
||
42 | * @param Finder $finder |
||
43 | * @param \finfo $fileInfo |
||
44 | */ |
||
45 | public function __construct(Filesystem $filesystem = null, Finder $finder = null, $fileInfo = null) |
||
51 | |||
52 | /** |
||
53 | * @param ArrayNodeDefinition $builder |
||
54 | */ |
||
55 | public function configure(ArrayNodeDefinition $builder) |
||
71 | |||
72 | /** |
||
73 | * @return \Closure |
||
74 | */ |
||
75 | private function getClearScreenshotDirectoryFeatureValidator() |
||
81 | |||
82 | |||
83 | /** |
||
84 | * @param ContainerBuilder $container |
||
85 | * @param array $config |
||
86 | */ |
||
87 | public function load(ContainerBuilder $container, array $config) |
||
96 | |||
97 | /** |
||
98 | * @param string $binaryImage |
||
99 | * @param string $filename |
||
100 | * |
||
101 | * @return string URL to the image |
||
102 | */ |
||
103 | public function upload($binaryImage, $filename) |
||
111 | |||
112 | /** |
||
113 | * @return string |
||
114 | */ |
||
115 | private function getDefaultDirectory() |
||
119 | |||
120 | /** |
||
121 | * @param string $fileName |
||
122 | * |
||
123 | * @return string |
||
124 | */ |
||
125 | private function getTargetPath($fileName) |
||
130 | |||
131 | /** |
||
132 | * @param string $directory |
||
133 | * |
||
134 | * @throws IOException |
||
135 | */ |
||
136 | private function ensureDirectoryExists($directory) |
||
146 | |||
147 | private function clearScreenshotDirectory() |
||
160 | } |
||
161 |