PluginProbe
Simple Analytics / 1.105
Simple Analytics v1.105
1.109 1.108 1.107 1.106 1.73 1.74 1.75 1.76 1.77 1.78 1.79 1.8 1.80 1.81 1.82 1.83 1.84 1.85 1.86 1.87 1.88 1.89 1.9 1.90 1.91 All 98 releases
simpleanalytics / tests / Pest.php

Pest.php in Simple Analytics 1.105, at tests/Pest.php

71 lines 2.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Tests;
4
5 /*
6 |--------------------------------------------------------------------------
7 | Test Case
8 |--------------------------------------------------------------------------
9 |
10 | The closure you provide to your test functions is always bound to a specific PHPUnit test
11 | case class. By default, that class is "PHPUnit\Framework\TestCase". Of course, you may
12 | need to change it using the "pest()" function to bind a different classes or traits.
13 |
14 */
15
16 use Pest\Browser\Api\Webpage;
17
18 pest()->extend(TestCase::class)->in('Feature');
19 pest()->browser()->timeout(30000);
20
21 /*
22 |--------------------------------------------------------------------------
23 | Expectations
24 |--------------------------------------------------------------------------
25 |
26 | When you're writing tests, you often need to check that values meet certain conditions. The
27 | "expect()" function gives you access to a set of "expectations" methods that you can use
28 | to assert different things. Of course, you may extend the Expectation API at any time.
29 |
30 */
31
32 expect()->extend('toBeOne', function () {
33 return $this->toBe(1);
34 });
35
36 /*
37 |--------------------------------------------------------------------------
38 | Functions
39 |--------------------------------------------------------------------------
40 |
41 | While Pest is very powerful out-of-the-box, you may have some testing code specific to your
42 | project that you don't want to repeat in every file. Here you can also expose helpers as
43 | global functions to help you to reduce the number of lines of code in your test files.
44 |
45 */
46
47 function asUser(string $login, string $password)
48 {
49 return visit('http://localhost:8100/wp-login.php')
50 ->assertPresent('#loginform')
51 ->fill('user_login', $login)
52 ->fill('user_pass', $password)
53 ->press('wp-submit')
54 ->assertPresent('#wpadminbar');
55 }
56
57 function asAdmin()
58 {
59 return asUser('admin', 'admin');
60 }
61
62 function asAuthor()
63 {
64 return asUser('author', 'author');
65 }
66
67 function asEditor()
68 {
69 return asUser('editor', 'editor');
70 }
71