Completed
Pull Request — master (#769)
by
unknown
04:54
created

ExecCest::testMultipleEnvVars()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.9332
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
class ExecCest
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
4
{
5
    // tests
6
    public function toExecLsCommand(CliGuy $I)
7
    {
8
        $command = strncasecmp(PHP_OS, 'WIN', 3) == 0 ? 'dir' : 'ls';
9
        $res = $I->taskExec($command)->interactive(false)->run();
10
        verify($res->getMessage())->contains('src');
11
        verify($res->getMessage())->contains('codeception.yml');
12
    }
13
14
    public function testMultipleEnvVars(CliGuy $I)
15
    {
16
        $task = $I->taskExec('env')->interactive(false);
17
        $task->env('FOO', 'BAR');
18
        $task->env('BAR', 'BAZ');
19
        $result = $task->run();
20
        // Verify that the text contains our environment variable.
21
        verify($result->getMessage())->contains('FOO=BAR');
22
        verify($result->getMessage())->contains('BAR=BAZ');
23
    }
24
25
    public function testInheritEnv(CliGuy $I)
26
    {
27
        // With no environment variables set, test that we have a known variable
28
        // such as PATH.
29
        $task = $I->taskExec('env | grep -E "^PATH="')->interactive(false);
30
        $result = $task->run();
31
        verify($result->getExitCode())->equals(\Robo\Result::EXITCODE_OK);
32
33
        // Now run the same command, but this time set an environment variable
34
        // on the task using ->env().
35
        $task = $I->taskExec('env | grep -E "^PATH="')->interactive(false);
36
        $task->env('FOO', 'BAR');
37
        $result = $task->run();
38
        verify($result->getExitCode())->equals(\Robo\Result::EXITCODE_OK);
39
    }
40
}
41