Skip to content
This repository was archived by the owner on Mar 6, 2022. It is now read-only.

Generate method test refactor #39

Merged
merged 2 commits into from
May 8, 2021
Merged

Conversation

dantleech
Copy link
Contributor

{
return [
'Empty file' => [
yield 'Empty file' => [
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

using generator instead

$tester->textDocument()->open(self::EXAMPLE_URI, self::EXAMPLE_SOURCE);

$promise = $tester->workspace()->executeCommand('generate', [self::EXAMPLE_URI, self::EXAMPLE_OFFSET]);
return $builder;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can add the command and open the text document with the test LS


self::assertNotNull($showMessage);
self::assertEquals([
'type' => 2,
'type' => MessageType::WARNING,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use the message type constant instead of a magic number


$applyEdit = $rpcClient->transmitter()->filterByMethod('workspace/applyEdit')->shiftRequest();
$builder = $this->createTester($generateMethod);
$builder->responseWatcher()->resolveLastResponse(new ApplyWorkspaceEditResponse(true));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the test LS can "respond" to requests.

@dantleech dantleech merged commit b048445 into master May 8, 2021
@dantleech dantleech deleted the generate-method-test-refactor branch May 8, 2021 07:24

class GenerateMethodCommandTest extends TestCase
{
use ProphecyTrait;
const EXAMPLE_SOURCE = '<?php ';
const EXAMPLE_URI = 'file:///file.php';
const EXAMPLE_OFFSET = 5;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use constants instead of local vars (which are acting as constants)

$tester = $builder->build();
$tester->textDocument()->open(self::EXAMPLE_URI, self::EXAMPLE_SOURCE);

$promise = $tester->workspace()->executeCommand('generate', [self::EXAMPLE_URI, self::EXAMPLE_OFFSET]);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm ... this is not right

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant