Skip to content

[OptimizeUse] add failing test for issue 33 #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions features/optimize_use.feature
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,39 @@ Feature: Optimize use

return $service;
"""
Scenario: Duplicate imports should not be allowed
Given a PHP File named "src/Foo.php" with:
"""
<?php

class Foo
{
public function throw1()
{
throw new \RuntimeException();
}

public function throw2()
{
throw new \RuntimeException();
}
}
"""
When I use refactoring "optimize-use" with:
| arg | value |
| file | src/Foo.php |
Then the PHP File "src/Foo.php" should be refactored:
"""
--- a/vfs://project/src/Foo.php
+++ b/vfs://project/src/Foo.php
@@ -3,5 +3,6 @@

+use RuntimeException;
+
class Foo
@@ -12,5 +12,5 @@

- throw new \RuntimeException();
+ throw new RuntimeException();

"""