File tree Expand file tree Collapse file tree 3 files changed +51
-1
lines changed
Expand file tree Collapse file tree 3 files changed +51
-1
lines changed Original file line number Diff line number Diff line change 3131 "squizlabs/php_codesniffer" : " ^3.5" ,
3232 "mikey179/vfsstream" : " ^1.6" ,
3333 "vimeo/psalm" : " ^4.3" ,
34- "phpro/grumphp" : " ^0.19 || ^1.2.0"
34+ "phpro/grumphp" : " ^0.19 || ^1.2.0" ,
35+ "codeception/codeception" : " ^4.1"
36+ },
37+ "suggest" : {
38+ "codeception/codeception" : " Use helper to handle clock with your codeception tests"
3539 }
3640}
Original file line number Diff line number Diff line change 55 <include >
66 <directory suffix =" .php" >src</directory >
77 </include >
8+ <exclude >
9+ <directory suffix =" .php" >src/CodeceptionHelper</directory >
10+ </exclude >
811 </coverage >
912 <testsuites >
1013 <testsuite name =" Project Test Suite" >
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ /**
4+ * @author: Julien Mercier-Rojas <[email protected] > 5+ * Created at: 25/03/2021
6+ */
7+
8+ declare (strict_types=1 );
9+
10+ namespace JeckelLab \Clock \CodeceptionHelper ;
11+
12+ use Codeception \Configuration ;
13+ use Codeception \Module ;
14+ use RuntimeException ;
15+
16+ /**
17+ * Class Clock
18+ * @package JeckelLab\Clock\CodeceptionHelper
19+ */
20+ class Clock extends Module
21+ {
22+ /**
23+ * @var array
24+ */
25+ protected $ requiredFields = ['fake_time_path ' ];
26+
27+ /**
28+ * Expected format 'Y-m-d H:i:s'
29+ * @Given current date and time is :currentDate
30+ * @param string $currentDate
31+ */
32+ public function currentDateAndTimeIs (string $ currentDate ): void
33+ {
34+ /** @psalm-suppress MixedArrayAccess */
35+ $ fullPath = Configuration::projectDir () . ((string ) $ this ->config ['fake_time_path ' ]);
36+
37+ $ dir = dirname ($ fullPath );
38+ if (!is_dir ($ dir ) && !mkdir ($ dir ) && !is_dir ($ dir )) {
39+ throw new RuntimeException (sprintf ('Directory "%s" was not created ' , $ dir ));
40+ }
41+ file_put_contents ($ fullPath , $ currentDate );
42+ }
43+ }
You can’t perform that action at this time.
0 commit comments