Skip to content

Commit

Permalink
Add failing test
Browse files Browse the repository at this point in the history
  • Loading branch information
brendt authored and gturpin-dev committed Nov 8, 2024
1 parent 0a72ea4 commit 082695e
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
24 changes: 24 additions & 0 deletions tests/Fixtures/Console/CommandWithArgumentName.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

namespace Tests\Tempest\Fixtures\Console;

use Tempest\Console\ConsoleArgument;
use Tempest\Console\ConsoleCommand;
use Tempest\Console\HasConsole;

final readonly class CommandWithArgumentName
{
use HasConsole;

#[ConsoleCommand(name: 'command-with-argument-name')]
public function __invoke(
#[ConsoleArgument(name: 'new-name')]
string $input,
#[ConsoleArgument(name: 'new-flag')]
bool $flag = false,
): void
{
$this->writeln($input);
$this->writeln($flag ? 'true' : 'false');
}
}
11 changes: 9 additions & 2 deletions tests/Integration/Console/ConsoleArgumentBagTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ public function test_positional_vs_named_input(): void
$this->console
->call('complex a --c=c --b=b --flag')
->assertContains('abc')
->assertContains('true')
;
->assertContains('true');
}

public function test_combined_flags(): void
Expand Down Expand Up @@ -138,4 +137,12 @@ public function test_negative_input(string $name, bool $expected): void

$this->assertSame($expected, $bag->findFor($definition)->value);
}

public function test_name_mapping(): void
{
$this->console
->call('command-with-argument-name --new-name=foo --new-flag')
->assertSee('foo')
->assertSee('true');
}
}

0 comments on commit 082695e

Please # to comment.