Skip to content

Commit c6896c6

Browse files
Steven Rémotstevenremot
Steven Rémot
authored andcommitted
Migrate integration tests in ecukes
1 parent 0fab6e2 commit c6896c6

10 files changed

+232
-387
lines changed

Cask

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
(source melpa)
22

3-
(package "ede-php-autoload" "0.4.1" "PHP autoloading implementation for Semantic")
3+
(package "ede-php-autoload" "0.4.2" "PHP autoloading implementation for Semantic")
44

55
(files "*.el" "ede-php-autoload")
66

77
(development
8-
(depends-on "ert-runner"))
8+
(depends-on "ecukes")
9+
(depends-on "f"))

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ CASK=cask
33
.PHONY: test test-simple elc package clean
44

55
test-simple:
6-
$(CASK) exec ert-runner
6+
$(CASK) exec ecukes
77

88
test:
99
$(MAKE) clean
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
Feature: Class name completion
2+
3+
Scenario: Complete PSR-0 namespaces
4+
Given I visit "src/main.php" in project "without-composer"
5+
Then completions for query "Psr0" should be:
6+
| Psr0Ns | Psr0Split\Ns1 | Psr0Split\Ns2 |
7+
8+
Scenario: Complete PSR-0 namespace with slashes
9+
Given I visit "src/main.php" in project "without-composer"
10+
Then completions for query "Psr0Ns\T" should be:
11+
| TheClass |
12+
13+
Scenario: Complete PSR-0 namespace with underscores
14+
Given I visit "src/main.php" in project "without-composer"
15+
Then completions for query "Psr0Ns_T" should be:
16+
| Psr0Ns_TheClass |
17+
18+
Scenario: Complete PSR-4 namespaces
19+
Given I visit "src/main.php" in project "without-composer"
20+
Then completions for query "Psr4" should be:
21+
| Psr4Ns | Psr4Split\Ns1 | Psr4Split\Ns2 |
22+
And completions for query "Psr4Ns\T" should be:
23+
| TheClass |
24+
25+
Scenario: Complete PSR-4 multi-dir namespaces
26+
Given I visit "src/main.php" in project "without-composer"
27+
Then completions for query "MultiDirNs\T" should be:
28+
| TheClass1 | TheClass2 |
29+
30+
Scenario: Complete classmap namespaces
31+
Given I visit "src/main.php" in project "without-composer"
32+
Then completions for query "ClassMapNs\" should be:
33+
| ClassMapNs\MyClass |
+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
Feature: Composer EDE project creation
2+
3+
Scenario: Visit a file in the EDE project
4+
Given I visit "src/main.php" in project "with-composer"
5+
Then ede-php-autoload-project should exist
6+
7+
8+
Scenario: Load a basic PSR-0 class
9+
Given I visit "src/main.php" in project "with-composer"
10+
Then the class "Psr0Ns_TheClass" should be detected in "src/Psr0Ns/TheClass.php"
11+
12+
Scenario: Load a PSR-0 class using fallback
13+
Given I visit "src/main.php" in project "with-composer"
14+
Then the class "Psr0Fallback_MyClass" should be detected in "src/Fallback/Psr0/Psr0Fallback/MyClass.php"
15+
16+
17+
Scenario: Load a basic PSR-4 class
18+
Given I visit "src/main.php" in project "with-composer"
19+
Then the class "Psr4Ns\TheClass" should be detected in "src/Psr4Ns/TheClass.php"
20+
21+
Scenario: Load a PSR-4 multi-directory namespace
22+
Given I visit "src/main.php" in project "with-composer"
23+
Then the class "MultiDirNs\\TheClass1" should be detected in "src/MultiDirNs1/TheClass1.php"
24+
And the class "MultiDirNs\\TheClass2" should be detected in "src/MultiDirNs2/TheClass2.php"
25+
26+
Scenario: Load a PSR-4 class using fallback
27+
Given I visit "src/main.php" in project "with-composer"
28+
Then the class "Psr4Fallback\MyClass" should be detected in "src/Fallback/Psr4/Psr4Fallback/MyClass.php"
29+
30+
Scenario: Load a class the doesn't exist
31+
Given I visit "src/main.php" in project "with-composer"
32+
Then the class "Psr4Ns\DoesNotExist" should not be detected
33+
34+
Scenario: Load an autoload-dev class
35+
Given I visit "src/main.php" in project "with-composer"
36+
Then the class "AutoloadDev\TestClass" should be detected in "src/AutoloadDev/TestClass.php"
37+
38+
Scenario: Load a dependency class
39+
Given I visit "src/main.php" in project "with-composer"
40+
Then the class "ThirdParty\ThirdClass" should be detected in "vendor/third-party/third-party/src/ThirdClass.php"
41+
42+
Scenario: Load a dependency with a target dir
43+
Given I visit "src/main.php" in project "with-composer"
44+
Then the class "TargetDir\Component\TheClass" should be detected in "vendor/target-dir/target-dir/TargetDir/Component/TheClass.php"
45+
46+
Scenario: Load a composer dev dependency class
47+
Given I visit "src/main.php" in project "with-composer"
48+
Then the class "DevDependency\TestClass" should be detected in "vendor/third-party/dev-dependency/src/TestClass.php"

features/ede-php-autoload.feature

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
Feature: Hand-made EDE project creation
2+
3+
Scenario: Visit a file in the ede project
4+
Given I visit "src/main.php" in project "without-composer"
5+
Then ede-php-autoload-project should exist
6+
And ede-php-autoload-project should have "." as include path
7+
And ede-php-autoload-project should have "/usr/share/php" as system include path
8+
9+
Scenario: Visit a directory in the ede project
10+
Given I visit "." in project "without-composer"
11+
Then ede-php-autoload-project should exist
12+
13+
Scenario: Load a basic PSR-0 class
14+
Given I visit "src/main.php" in project "without-composer"
15+
Then the class "Psr0Ns_TheClass" should be detected in "src/Psr0Ns/TheClass.php"
16+
17+
Scenario: Load a split PSR-0 namespace
18+
Given I visit "src/main.php" in project "without-composer"
19+
Then the class "Psr0Split\Ns2\TheClass" should be detected in "src/Psr0Split/Ns2/TheClass.php"
20+
21+
Scenario: Load a basic PSR-4 class
22+
Given I visit "src/main.php" in project "without-composer"
23+
Then the class "Psr4Ns\TheClass" should be detected in "src/Psr4Ns/TheClass.php"
24+
25+
Scenario: Load a split PSR-4 namespace
26+
Given I visit "src/main.php" in project "without-composer"
27+
Then the class "Psr4Split\Ns2\TheClass" should be detected in "src/Psr4Split/Ns2/TheClass.php"
28+
29+
Scenario: Load a PSR-4 multi-directory namespace
30+
Given I visit "src/main.php" in project "without-composer"
31+
Then the class "MultiDirNs\\TheClass1" should be detected in "src/MultiDirNs1/TheClass1.php"
32+
And the class "MultiDirNs\\TheClass2" should be detected in "src/MultiDirNs2/TheClass2.php"
33+
34+
Scenario: Guess a PSR-4 class name
35+
Given I visit "src/main.php" in project "without-composer"
36+
Then guessing the class name for "src/MultiDirNs1/SubNs1/SubNs2/Class.php" should return "MultiDirNs\SubNs1\SubNs2\Class"
37+
38+
Scenario: Guess a split PSR-4 class name
39+
Given I visit "src/main.php" in project "without-composer"
40+
Then guessing the class name for "src/Psr4Split/Ns2/MyClass.php" should return "Psr4Split\Ns2\MyClass"
41+
42+
Scenario: Load a classmap class
43+
Given I visit "src/main.php" in project "without-composer"
44+
Then the class "ClassMapNs\MyClass" should be detected in "src/ClassMapNs/MyClass.php"
45+
46+
Scenario: Guess a classmap class name
47+
Given I visit "src/main.php" in project "without-composer"
48+
THen guessing the class name for "src/ClassMapNs/MyClass.php" should return "ClassMapNs\MyClass"
49+
50+
51+
Scenario: Load a class the doesn't exist
52+
Given I visit "src/main.php" in project "without-composer"
53+
Then the class "Psr4Ns\DoesNotExist" should not be detected
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
(Given "^I visit \"\\(.+\\)\" in project \"\\(.+\\)\"$"
2+
(lambda (file-path project-name)
3+
(find-file (ede-php-autoload-test-get-project-file-path file-path project-name))
4+
))
5+
6+
(Then "^ede-php-autoload-project should exist$"
7+
(lambda ()
8+
(should (ede-php-autoload-project-p (ede-current-project)))))
9+
10+
(Then "^ede-php-autoload-project should have \"\\(.+\\)\" as include path"
11+
(lambda (include-path)
12+
(should (string= (car (oref (ede-current-project) :include-path)) include-path))))
13+
14+
(Then "^ede-php-autoload-project should have \"\\(.+\\)\" as system include path"
15+
(lambda (include-path)
16+
(should (string= (car (oref (ede-current-project) :system-include-path)) include-path))))
17+
18+
(Then "^the class \"\\(.+\\)\" should be detected in \"\\(.+\\)\"$"
19+
(lambda (class-name file-path)
20+
(should
21+
(string=
22+
(ede-php-autoload-test-get-project-file-path
23+
file-path
24+
(ede-php-autoload-test-get-current-project-name))
25+
(ede-php-autoload-find-class-def-file (ede-current-project) class-name)))))
26+
27+
(Then "^the class \"\\(.+\\)\" should not be detected"
28+
(lambda (class-name)
29+
(should-not (ede-php-autoload-find-class-def-file (ede-current-project) class-name))))
30+
31+
(Then "^guessing the class name for \"\\(.+\\)\" should return \"\\(.+\\)\""
32+
(lambda (file-name class-name)
33+
(should (string= (ede-php-autoload-get-class-name-for-file
34+
(ede-current-project)
35+
file-name)
36+
class-name))))
37+
38+
(Then "^completions for query \"\\(.+\\)\" should be:"
39+
(lambda (query suggestion-table)
40+
(should (equal (ede-php-autoload-complete-type-name (ede-current-project) query)
41+
(car suggestion-table)))))

features/support/env.el

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
(require 'package)
2+
(require 'f)
3+
(require 'cl-lib)
4+
(require 'ert)
5+
(require 'eieio)
6+
7+
(defvar ede-php-autoload-support-path
8+
(f-dirname load-file-name))
9+
10+
(defvar ede-php-autoload-features-path
11+
(f-parent ede-php-autoload-support-path))
12+
13+
(defvar ede-php-autoload-root-path
14+
(f-parent ede-php-autoload-features-path))
15+
16+
(defvar ede-php-autoload-test-projects-root-path
17+
(f-join ede-php-autoload-root-path "test/projects"))
18+
19+
(defun ede-php-autoload-test-get-project-file-path (file project)
20+
"Return the absolute path for FILE relative to PROJECT."
21+
(f-join ede-php-autoload-test-projects-root-path project file))
22+
23+
(defun ede-php-autoload-test-get-current-project-name ()
24+
"Return the test project currently visited."
25+
(car
26+
(f-split
27+
(f-relative
28+
(or (buffer-file-name) default-directory)
29+
ede-php-autoload-test-projects-root-path))))
30+
31+
(add-to-list 'load-path ede-php-autoload-root-path)
32+
33+
(package-generate-autoloads "ede-php-autoload" ede-php-autoload-root-path)
34+
(load (f-join ede-php-autoload-root-path "ede-php-autoload-autoloads.el"))
35+
36+
(Setup
37+
(global-ede-mode 1)
38+
;; Define projects
39+
;; The composer projet is auto-detected
40+
(ede-php-autoload-project "Without composer"
41+
:file (f-join ede-php-autoload-test-projects-root-path
42+
"without-composer/project")
43+
:class-autoloads '(:psr-0 (("Psr0Ns" . "src/Psr0Ns")
44+
("Psr0Split\\Ns1" . "src/Psr0Split/Ns1")
45+
("Psr0Split\\Ns2" . "src/Psr0Split/Ns2"))
46+
:psr-4 (("Psr4Ns" . "src/Psr4Ns")
47+
("MultiDirNs" . ("src/MultiDirNs1" "src/MultiDirNs2"))
48+
("Psr4Split\\Ns1" . "src/Psr4Split/Ns1")
49+
("Psr4Split\\Ns2" . "src/Psr4Split/Ns2"))
50+
:class-map ((ClassMapNs\\MyClass . "src/ClassMapNs/MyClass.php")))
51+
:include-path '(".")
52+
:system-include-path '("/usr/share/php"))
53+
)

test/ede-php-autoload-composer-test.el

-102
This file was deleted.

0 commit comments

Comments
 (0)