Skip to content

Commit

Permalink
Move tests from ProcessResolveTest
Browse files Browse the repository at this point in the history
  • Loading branch information
thekid committed Mar 23, 2024
1 parent 3ed4143 commit df9e43f
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 128 deletions.
53 changes: 52 additions & 1 deletion src/test/php/lang/unittest/CommandLineTest.class.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?php namespace lang\unittest;

use lang\CommandLine;
use test\{Assert, Test};
use test\verify\Runtime;
use test\{Assert, Test, Values};

class CommandLineTest {

Expand Down Expand Up @@ -264,4 +265,54 @@ public function evalCommandLineWindowsTripleClosedBySingle() {
CommandLine::$WINDOWS->parse($cmd)
);
}

#[Test, Values(eval: 'CommandLine::values()')]
public function resolve_non_existant($impl) {
Assert::false($impl->resolve('@non-existant@')->valid());
}

#[Test, Values(eval: 'CommandLine::values()')]
public function resolve_empty($impl) {
Assert::false($impl->resolve('')->valid());
}

#[Test]
public function resolve_path_on_unix() {
Assert::false(CommandLine::$UNIX->resolve('/')->valid());
}

#[Test, Runtime(os: 'Linux|Darwin')]
public function resolve_ls_on_unix() {
Assert::true(is_executable(CommandLine::$UNIX->resolve('ls')->current()));
}

#[Test, Runtime(os: 'Linux|Darwin')]
public function resolve_absolute_on_unix() {
Assert::true(is_executable(CommandLine::$UNIX->resolve('/bin/ls')->current()));
}

#[Test]
public function resolve_path_on_win() {
Assert::false(CommandLine::$WINDOWS->resolve('\\')->valid());
}

#[Test, Runtime(os: '^Win')]
public function resolve_explorer_on_win() {
Assert::true(is_executable(CommandLine::$WINDOWS->resolve('explorer')->current()));
}

#[Test, Runtime(os: '^Win')]
public function resolve_with_extension_on_win() {
Assert::true(is_executable(CommandLine::$WINDOWS->resolve('explorer.exe')->current()));
}

#[Test, Runtime(os: '^Win')]
public function resolve_absolute_on_win() {
Assert::true(is_executable(CommandLine::$UNIX->resolve(getenv('WINDIR').'\\explorer.exe')->current()));
}

#[Test, Runtime(os: '^Win')]
public function resolve_quoted_on_win() {
Assert::true(is_executable(CommandLine::$WINDOWS->resolve('"explorer"')->current()));
}
}
127 changes: 0 additions & 127 deletions src/test/php/lang/unittest/ProcessResolveTest.class.php

This file was deleted.

0 comments on commit df9e43f

Please sign in to comment.