File: ExecCommandTest.php

package info (click to toggle)
composer 2.8.8-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 10,716 kB
  • sloc: php: 77,384; makefile: 59; xml: 39
file content (60 lines) | stat: -rw-r--r-- 1,558 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php declare(strict_types=1);

/*
 * This file is part of Composer.
 *
 * (c) Nils Adermann <naderman@naderman.de>
 *     Jordi Boggiano <j.boggiano@seld.be>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Composer\Test\Command;

use Composer\Test\TestCase;

class ExecCommandTest extends TestCase
{
    public function testListThrowsIfNoBinariesExist(): void
    {
        $composerDir = $this->initTempComposer();

        $composerBinDir = "$composerDir/vendor/bin";
        $this->expectException(\RuntimeException::class);
        $this->expectExceptionMessage(
            "No binaries found in composer.json or in bin-dir ($composerBinDir)"
        );

        $appTester = $this->getApplicationTester();
        $appTester->run(['command' => 'exec', '--list' => true]);
    }

    public function testList(): void
    {
        $composerDir = $this->initTempComposer([
            'bin' => [
                'a'
            ]
        ]);

        $composerBinDir = "$composerDir/vendor/bin";
        mkdir($composerBinDir, 0777, true);
        touch($composerBinDir . '/b');
        touch($composerBinDir . '/b.bat');
        touch($composerBinDir . '/c');

        $appTester = $this->getApplicationTester();
        $appTester->run(['command' => 'exec', '--list' => true]);

        $output = $appTester->getDisplay(true);

        self::assertSame(
            'Available binaries:
- b
- c
- a (local)',
            trim($output)
        );
    }
}