Skip to content

Commit

Permalink
Merge pull request #3 from RxChin/main
Browse files Browse the repository at this point in the history
Main
  • Loading branch information
RxChin authored Sep 7, 2023
2 parents 254d795 + ecad89d commit 5201a5a
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 36 deletions.
36 changes: 0 additions & 36 deletions .github/workflows/deploy.yml

This file was deleted.

23 changes: 23 additions & 0 deletions tests/Unit/Component/Finder/Administrator/Indexer/ResultTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,27 @@ public function testSetAndGetElement(): void
// Attempt to get a non-existent element should return null
$this->assertNull($obj->getElement('non_existent_key'));
}
public function testSetAndGetElementWithEmptyValue(): void
{
// Create a new Result object
$obj = $this->createNoConstructorMock();

// Set an element with an empty value
$obj->setElement('key1', '');

// Get the element and assert its value
$this->assertEquals('', $obj->getElement('key1'));

// Set another element with an empty value
$obj->setElement('key2', '');

// Get the second element and assert its value
$this->assertEquals('', $obj->getElement('key2'));

// Attempt to get a non-existent element should return null
$this->assertNull($obj->getElement('non_existent_key'));


}
}

56 changes: 56 additions & 0 deletions tests/Unit/Libraries/Cms/Application/ConsoleApplicationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,60 @@ protected function createApplication(): ConsoleApplication

return $object;
}


/**
* @testdox Test that the ConsoleApplication correctly processes command-line arguments
*
* @return void
* @since 4.0.0
*/
public function testCommandLineArguments()
{
$app = $this->createApplication();

// Simulate passing command-line arguments as an array
$commandLineArguments = ['script_name.php', 'custom:command', '--option=value', 'argument1', 'argument2'];

// Set the input arguments of the application
$app->setCommandLineArguments($commandLineArguments);

// Get the input interface to retrieve command-line arguments
$input = $app->getInput();

// Assert that the script name is correctly set as the first argument
$this->assertEquals('script_name.php', $input->getArgument('script_name'));

// Assert that the custom command is correctly set as the second argument
$this->assertEquals('custom:command', $input->getArgument('command'));

// Assert that the option is correctly set as an option
$this->assertEquals('value', $input->getOption('option'));

// Assert that the arguments are correctly set
$this->assertEquals(['argument1', 'argument2'], $input->getArguments());
}
/**
* @testdox Test that the ConsoleApplication can set and retrieve the language
*
* @return void
* @since 4.0.0
*/
public function testSetAndGetLanguage()
{
$app = $this->createApplication();

// Create a mock Language object
$language = $this->createMock(Language::class);

// Set the language for the application
$app->setLanguage($language);

// Get the language from the application
$retrievedLanguage = $app->getLanguage();

// Assert that the retrieved language is the same as the mock Language object
$this->assertSame($language, $retrievedLanguage);
}

}

0 comments on commit 5201a5a

Please sign in to comment.