File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -103,7 +103,7 @@ class OptionalPackages
103103 */
104104 private $ stabilityFlags ;
105105
106- public function __construct (IOInterface $ io , Composer $ composer , string $ projectRoot = null )
106+ public function __construct (IOInterface $ io , Composer $ composer , ? string $ projectRoot = null )
107107 {
108108 $ this ->io = $ io ;
109109 $ this ->composer = $ composer ;
@@ -139,11 +139,13 @@ function ($value) {
139139 'n '
140140 );
141141
142- if ($ answer != 'n ' ) {
143- $ content = file_get_contents ($ this ->installerSource . '/resources/bin/hyperf.stub ' );
144- $ content = str_replace ('%TIME_ZONE% ' , $ answer , $ content );
145- file_put_contents ($ this ->projectRoot . '/bin/hyperf.php ' , $ content );
142+ if ($ answer == 'n ' ) {
143+ $ answer = date_default_timezone_get ();
146144 }
145+
146+ $ content = file_get_contents ($ this ->installerSource . '/resources/bin/hyperf.stub ' );
147+ $ content = str_replace ('%TIME_ZONE% ' , $ answer , $ content );
148+ file_put_contents ($ this ->projectRoot . '/bin/hyperf.php ' , $ content );
147149 }
148150
149151 /**
Original file line number Diff line number Diff line change 7171 'hyperf/service-governance ' => [
7272 'version ' => '~3.1.0 ' ,
7373 ],
74+ 'pestphp/pest ' => [
75+ 'version ' => '^2.34 ' ,
76+ ],
7477 ],
7578 'require-dev ' => [
79+ 'pestphp/pest ' ,
7680 ],
7781 'questions ' => [
7882 'database ' => [
310314 ],
311315 ],
312316 ],
317+ 'pest ' => [
318+ 'question ' => 'Do you want to use pestphp/pest component ? (Pest is a testing framework with a focus on simplicity,
319+ meticulously designed to bring back the joy of testing in PHP.) ' ,
320+ 'default ' => 'n ' ,
321+ 'required ' => false ,
322+ 'force ' => true ,
323+ 'custom-package ' => true ,
324+ 'options ' => [
325+ 'y ' => [
326+ 'name ' => 'yes ' ,
327+ 'packages ' => [
328+ 'pestphp/pest ' ,
329+ ],
330+ 'resources ' => [
331+ 'resources/pest/Feature/ExampleTest.php ' => 'test/Feature/ExampleTest.php ' ,
332+ 'resources/pest/Unit/ExampleTest.php ' => 'test/Unit/ExampleTest.php ' ,
333+ 'resources/pest/Pest.php ' => 'test/Pest.php ' ,
334+ 'resources/pest/TestCase.php ' => 'test/TestCase.php ' ,
335+ ],
336+ ],
337+ ],
338+ ],
313339 ],
314340];
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ test ('example ' , function () {
4+ expect (true )->toBeTrue ();
5+ });
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ /*
4+ |--------------------------------------------------------------------------
5+ | Test Case
6+ |--------------------------------------------------------------------------
7+ |
8+ | The closure you provide to your test functions is always bound to a specific PHPUnit test
9+ | case class. By default, that class is "PHPUnit\Framework\TestCase". Of course, you may
10+ | need to change it using the "uses()" function to bind a different classes or traits.
11+ |
12+ */
13+
14+ // uses(Tests\TestCase::class)->in('Feature');
15+
16+ /*
17+ |--------------------------------------------------------------------------
18+ | Expectations
19+ |--------------------------------------------------------------------------
20+ |
21+ | When you're writing tests, you often need to check that values meet certain conditions. The
22+ | "expect()" function gives you access to a set of "expectations" methods that you can use
23+ | to assert different things. Of course, you may extend the Expectation API at any time.
24+ |
25+ */
26+
27+ expect ()->extend ('toBeOne ' , function () {
28+ return $ this ->toBe (1 );
29+ });
30+
31+ /*
32+ |--------------------------------------------------------------------------
33+ | Functions
34+ |--------------------------------------------------------------------------
35+ |
36+ | While Pest is very powerful out-of-the-box, you may have some testing code specific to your
37+ | project that you don't want to repeat in every file. Here you can also expose helpers as
38+ | global functions to help you to reduce the number of lines of code in your test files.
39+ |
40+ */
41+
42+ function something ()
43+ {
44+ // ..
45+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Tests ;
4+
5+ use PHPUnit \Framework \TestCase as BaseTestCase ;
6+
7+ abstract class TestCase extends BaseTestCase
8+ {
9+ //
10+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ test ('example ' , function () {
4+ expect (true )->toBeTrue ();
5+ });
Original file line number Diff line number Diff line change 99 * @contact group@hyperf.io
1010 * @license https://github.com/hyperf/hyperf/blob/master/LICENSE
1111 */
12+ use Hyperf \Contract \ApplicationInterface ;
13+ use Hyperf \Di \ClassLoader ;
14+ use Hyperf \Engine \DefaultOption ;
15+
1216ini_set ('display_errors ' , 'on ' );
1317ini_set ('display_startup_errors ' , 'on ' );
1418
1519error_reporting (E_ALL );
1620date_default_timezone_set ('Asia/Shanghai ' );
1721
18- Swoole \Runtime::enableCoroutine (true );
19-
2022! defined ('BASE_PATH ' ) && define ('BASE_PATH ' , dirname (__DIR__ , 1 ));
2123
2224require BASE_PATH . '/vendor/autoload.php ' ;
2325
24- ! defined ('SWOOLE_HOOK_FLAGS ' ) && define ('SWOOLE_HOOK_FLAGS ' , Hyperf \ Engine \ DefaultOption::hookFlags ());
26+ ! defined ('SWOOLE_HOOK_FLAGS ' ) && define ('SWOOLE_HOOK_FLAGS ' , DefaultOption::hookFlags ());
2527
26- Hyperf \ Di \ ClassLoader::init ();
28+ ClassLoader::init ();
2729
2830$ container = require BASE_PATH . '/config/container.php ' ;
2931
30- $ container ->get (Hyperf \ Contract \ ApplicationInterface::class);
32+ $ container ->get (ApplicationInterface::class);
You can’t perform that action at this time.
0 commit comments