File: ClearCacheCommandTest.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 (61 lines) | stat: -rw-r--r-- 1,771 bytes parent folder | download | duplicates (2)
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
61
<?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;
use Composer\Util\Platform;

class ClearCacheCommandTest extends TestCase
{
    public function tearDown(): void
    {
        // --no-cache triggers the env to change so make sure the env is cleaned up after these tests run
        Platform::clearEnv('COMPOSER_CACHE_DIR');
    }

    public function testClearCacheCommandSuccess(): void
    {
        $appTester = $this->getApplicationTester();
        $appTester->run(['command' => 'clear-cache']);

        $appTester->assertCommandIsSuccessful();

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

        self::assertStringContainsString('All caches cleared.', $output);
    }

    public function testClearCacheCommandWithOptionGarbageCollection(): void
    {
        $appTester = $this->getApplicationTester();
        $appTester->run(['command' => 'clear-cache', '--gc' => true]);

        $appTester->assertCommandIsSuccessful();

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

        self::assertStringContainsString('All caches garbage-collected.', $output);
    }

    public function testClearCacheCommandWithOptionNoCache(): void
    {
        $appTester = $this->getApplicationTester();
        $appTester->run(['command' => 'clear-cache', '--no-cache' => true]);

        $appTester->assertCommandIsSuccessful();

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

        self::assertStringContainsString('Cache is not enabled', $output);
    }
}