|
| 1 | +<?php |
| 2 | + |
| 3 | +use function Cfx\PSpec\get; |
| 4 | +use function Cfx\PSpec\getSubject; |
| 5 | +use function Cfx\PSpec\let; |
| 6 | +use function Cfx\PSpec\subject; |
| 7 | + |
| 8 | +describe('class_name', function () { |
| 9 | + subject(fn () => get('variable')); |
| 10 | + |
| 11 | + let('variable', fn () => 'from root'); |
| 12 | + |
| 13 | + it('gets the variable from root variable') |
| 14 | + ->expect(getSubject(...)) |
| 15 | + ->toEqual('from root'); |
| 16 | + |
| 17 | + describe('.method_name', function () { |
| 18 | + it('gets the variable from root variable') |
| 19 | + ->expect(getSubject(...)) |
| 20 | + ->toEqual('from root'); |
| 21 | + |
| 22 | + describe('can override', function () { |
| 23 | + let('variable', fn () => 'overrided'); |
| 24 | + |
| 25 | + it('gets the variable from local scope') |
| 26 | + ->expect(getSubject(...)) |
| 27 | + ->toEqual('overrided'); |
| 28 | + |
| 29 | + describe('sub nested block', function () { |
| 30 | + it('gets variable from parent block') |
| 31 | + ->expect(getSubject(...)) |
| 32 | + ->toEqual('overrided'); |
| 33 | + }); |
| 34 | + }); |
| 35 | + }); |
| 36 | +}); |
| 37 | + |
| 38 | +describe('no direct tests block', function () { |
| 39 | + subject(fn () => get('variable2')); |
| 40 | + |
| 41 | + let('variable2', fn () => 'from root'); |
| 42 | + |
| 43 | + describe('nested block', function () { |
| 44 | + it('gets the variable from root variable') |
| 45 | + ->expect(getSubject(...)) |
| 46 | + ->toEqual('from root'); |
| 47 | + }); |
| 48 | +}); |
0 commit comments