branch: externals/phps-mode
commit 968f7b067ca2d096109a3bd4aec232b21cda0b55
Author: Christian Johansson <[email protected]>
Commit: Christian Johansson <[email protected]>

    Moved all imenu tests to AST tests
---
 test/phps-mode-test-ast.el          | 80 +++++++++++++++++++++++++++++++
 test/phps-mode-test-lex-analyzer.el | 96 -------------------------------------
 2 files changed, 80 insertions(+), 96 deletions(-)

diff --git a/test/phps-mode-test-ast.el b/test/phps-mode-test-ast.el
index 09be4b461b..1a4e62a08a 100644
--- a/test/phps-mode-test-ast.el
+++ b/test/phps-mode-test-ast.el
@@ -129,6 +129,86 @@
        phps-mode-ast--imenu
        '(("MyNamespaceA" ("aFunctionA" . 46) ("MyClass" ("__construct" . 205) 
("myFunction1" . 338) ("myFunction2" . 542) ("myFunction3" . 646) 
("myFunction4" . 740))) ("aFunctionB" . 807) ("MyClass" ("__construct" . 925) 
("myFunction1" . 1058) ("myFunction2" . 1262) ("myFunction3" . 1366) 
("myFunction4" . 1460)))))))
 
+  (phps-mode-test-ast--buffer-contents
+  "<?php\nnamespace myNamespace {\n    class myClass extends myAbstract {\n    
    public function myFunctionA() {}\n        protected function myFunctionB() 
{}\n    }\n}\n"
+  "Imenu object-oriented file with namespace, class that extends and functions"
+  (lambda()
+     (phps-mode-ast-generate)
+     (should
+      (equal
+       phps-mode-ast--imenu
+       '(("myNamespace" ("myClass" ("myFunctionA" . 94) ("myFunctionB" . 
138))))))))
+
+  (phps-mode-test-ast--buffer-contents
+   "<?php\nnamespace myNamespace;\nclass myClass extends myAbstract implements 
myInterface {\n    public function myFunctionA() {}\n    protected function 
myFunctionB() {}\n}\n"
+   "Imenu object-oriented file with bracket-less namespace, class that extends 
and implements and functions"
+   (lambda()
+     (phps-mode-ast-generate)
+     (should
+      (equal
+       phps-mode-ast--imenu
+       '(("myNamespace" ("myClass" ("myFunctionA" . 108) ("myFunctionB" . 
148))))))))
+
+  (phps-mode-test-ast--buffer-contents
+   "<?php\nclass myClass {}"
+   "Imenu empty class"
+   (lambda()
+     (phps-mode-ast-generate)
+     (should
+      (equal
+       phps-mode-ast--imenu
+       '(("myClass" . 13))))))
+
+  (phps-mode-test-ast--buffer-contents
+   "<?php\nnamespace myNamespace {}"
+   "Imenu empty bracketed namespace"
+   (lambda()
+     (phps-mode-ast-generate)
+     (should
+      (equal
+       phps-mode-ast--imenu
+       '(("myNamespace" . 17))))))
+
+  (phps-mode-test-ast--buffer-contents
+   "<?php\nnamespace myNamespace;"
+   "Imenu empty namespace without brackets"
+   (lambda()
+     (phps-mode-ast-generate)
+     (should
+      (equal
+       phps-mode-ast--imenu
+       '(("myNamespace" . 17))))))
+
+  (phps-mode-test-ast--buffer-contents
+   "<?php\nnamespace myNamespace;\nclass myClass extends myAbstract implements 
myInterface {\n    public function myFunctionA($myArg = null) {}\n    protected 
function myFunctionB($myArg = 'abc') {}\n}\n"
+   "Imenu object-oriented file with bracket-less namespace, class that extends 
and implements and functions with optional arguments"
+   (lambda()
+     (phps-mode-ast-generate)
+     (should
+      (equal
+       phps-mode-ast--imenu
+       '(("myNamespace" ("myClass" ("myFunctionA" . 108) ("myFunctionB" . 
161))))))))
+
+  (phps-mode-test-ast--buffer-contents
+   "<?php\nnamespace myNamespace\\myNamespace2;\nclass myClass extends 
myAbstract implements myInterface {\n    public function myFunctionA($myArg = 
null) {}\n    protected function myFunctionB($myArg = 'abc') {}\n}\n"
+   "Imenu object-oriented file with bracket-less namespace with multiple 
levels, class that extends and implements and functions with optional arguments"
+   (lambda()
+     (phps-mode-ast-generate)
+     (should
+      (equal
+       phps-mode-ast--imenu
+       '(("myNamespace\\myNamespace2" ("myClass" ("myFunctionA" . 121) 
("myFunctionB" . 174))))))))
+
+  (phps-mode-test-ast--buffer-contents
+   "<?php\nnamespace {}"
+   "Imenu empty unnamed bracketed namespace"
+   (lambda()
+     (phps-mode-ast-generate)
+     (should
+      (equal
+       phps-mode-ast--imenu
+       nil))))
+
   (message "\n-- Ran tests for imenu generation. --"))
 
 (defun phps-mode-test-ast ()
diff --git a/test/phps-mode-test-lex-analyzer.el 
b/test/phps-mode-test-lex-analyzer.el
index 172eec894d..9fc97908ab 100644
--- a/test/phps-mode-test-lex-analyzer.el
+++ b/test/phps-mode-test-lex-analyzer.el
@@ -1156,101 +1156,6 @@
 
   )
 
-(defun phps-mode-test-lex-analyzer--imenu ()
-  "Test for imenu."
-
-  (phps-mode-test--with-buffer
-   "<?php\nfunction myFunctionA() {}\nfunction myFunctionB() {}\n$var = 
function () {\n    echo 'here';\n};"
-   "Imenu function-oriented file with anonymous function"
-   (should (equal (phps-mode-lex-analyzer--get-imenu) '(("myFunctionA" . 16) 
("myFunctionB" . 42)))))
-
-  (phps-mode-test--with-buffer
-   "<?php\nfunction myFunctionA() {}\nfunction myFunctionB() {}\n"
-   "Imenu function-oriented file"
-   (should (equal (phps-mode-lex-analyzer--get-imenu) '(("myFunctionA" . 16) 
("myFunctionB" . 42)))))
-
-  (phps-mode-test--with-buffer
-   "<?php\nclass myClass {\n    public function myFunctionA() {}\n    
protected function myFunctionB() {}\n}\n"
-   "Imenu object-oriented file"
-   (should (equal (phps-mode-lex-analyzer--get-imenu) '(("myClass" . 
(("myFunctionA" . 43) ("myFunctionB" . 83)))))))
-
-  (phps-mode-test--with-buffer
-   "<?php\ninterface myInterface {\n    public function myFunctionA() {}\n    
protected function myFunctionB() {}\n}\n"
-   "Imenu object-oriented file with interface"
-   (should (equal (phps-mode-lex-analyzer--get-imenu) '(("myInterface" . 
(("myFunctionA" . 51) ("myFunctionB" . 91)))))))
-
-  (phps-mode-test--with-buffer
-   "<?php\nnamespace myNamespace {\n    class myClass {\n        public 
function myFunctionA() {}\n        protected function myFunctionB() {}\n    
}\n}\n"
-   "Imenu object-oriented file with namespace, class and function"
-   (should (equal (phps-mode-lex-analyzer--get-imenu) '(("myNamespace" 
("myClass" ("myFunctionA" . 75) ("myFunctionB" . 119)))))))
-
-  (phps-mode-test--with-buffer
-   "<?php\nnamespace myNamespace;\nclass myClass {\n    public function 
myFunctionA() {}\n    protected function myFunctionB() {}\n}\n"
-   "Imenu object-oriented file with bracket-less namespace, class and function"
-   (should (equal (phps-mode-lex-analyzer--get-imenu) '(("myNamespace" 
("myClass" ("myFunctionA" . 66) ("myFunctionB" . 106)))))))
-
-  (phps-mode-test--with-buffer
-   "<?php\nnamespace myNamespace {\n    class myClass extends myAbstract {\n   
     public function myFunctionA() {}\n        protected function myFunctionB() 
{}\n    }\n}\n"
-   "Imenu object-oriented file with namespace, class that extends and 
functions"
-   (should (equal (phps-mode-lex-analyzer--get-imenu) '(("myNamespace" 
("myClass" ("myFunctionA" . 94) ("myFunctionB" . 138)))))))
-
-  (phps-mode-test--with-buffer
-   "<?php\nnamespace myNamespace;\nclass myClass extends myAbstract implements 
myInterface {\n    public function myFunctionA() {}\n    protected function 
myFunctionB() {}\n}\n"
-   "Imenu object-oriented file with bracket-less namespace, class that extends 
and implements and functions"
-   (should (equal (phps-mode-lex-analyzer--get-imenu) '(("myNamespace" 
("myClass" ("myFunctionA" . 108) ("myFunctionB" . 148)))))))
-
-  (phps-mode-test--with-buffer
-   "<?php\nnamespace myNamespace;\nclass myClass extends myAbstract implements 
myInterface {\n    public function myFunctionA($myArg = null) {}\n    protected 
function myFunctionB($myArg = 'abc') {}\n}\n"
-   "Imenu object-oriented file with bracket-less namespace, class that extends 
and implements and functions with optional arguments"
-   (should (equal (phps-mode-lex-analyzer--get-imenu) '(("myNamespace" 
("myClass" ("myFunctionA" . 108) ("myFunctionB" . 161)))))))
-
-  (phps-mode-test--with-buffer
-   "<?php\nnamespace myNamespace\\myNamespace2;\nclass myClass extends 
myAbstract implements myInterface {\n    public function myFunctionA($myArg = 
null) {}\n    protected function myFunctionB($myArg = 'abc') {}\n}\n"
-   "Imenu object-oriented file with bracket-less namespace with multiple 
levels, class that extends and implements and functions with optional arguments"
-   (should (equal (phps-mode-lex-analyzer--get-imenu) 
'(("myNamespace\\myNamespace2" ("myClass" ("myFunctionA" . 121) ("myFunctionB" 
. 174)))))))
-
-  (phps-mode-test--with-buffer
-   "<?php\nclass myClass\n{\n\n    public function myFunction1()\n    {\n      
  echo \"my string with variable {$variable} inside it\";\n    }\n\n    public 
function myFunction2()\n    {\n    }\n\n}"
-   "Imenu with double quoted string with variable inside it"
-   (should (equal (phps-mode-lex-analyzer--get-imenu) '(("myClass" 
("myFunction1" . 44) ("myFunction2" . 153))))))
-
-  (phps-mode-test--with-buffer
-   "<?php\n\nnamespace MyNamespace;\n\nclass MyClass\n{\n\n    /**\n     *\n   
  */\n    public function __construct()\n    {\n        if ($test) {\n        
}\n    }\n\n    /**\n     *\n     */\n    public function myFunction1()\n    
{\n        $this->addMessage(\"My random {$message} here\" . ($random > 1 ? 
\"A\" : \"\") . \" was here.\");\n    }\n    \n    /**\n     *\n     */\n    
public function myFunction2()\n    {\n    }\n\n    /**\n     * It's good\n     
*/\n    public function my [...]
-   "Imenu with double quoted string with variable inside it and concatenated 
string"
-   (should (equal (phps-mode-lex-analyzer--get-imenu) '(("MyNamespace" 
("MyClass" ("__construct" . 92) ("myFunction1" . 193) ("myFunction2" . 365) 
("myFunction3" . 445) ("myFunction4" . 515)))))))
-
-  (phps-mode-test--with-buffer
-   "<?php\nclass myClass {}"
-   "Imenu empty class"
-   (should (equal (phps-mode-lex-analyzer--get-imenu) nil)))
-
-  (phps-mode-test--with-buffer
-   "<?php\nnamespace myNamespace {}"
-   "Imenu empty bracketed namespace"
-   (should (equal (phps-mode-lex-analyzer--get-imenu) nil)))
-
-  (phps-mode-test--with-buffer
-   "<?php\nnamespace myNamespace;"
-   "Imenu empty namespace without brackets"
-   (should (equal (phps-mode-lex-analyzer--get-imenu) nil)))
-
-  (phps-mode-test--with-buffer
-   "<?php\ninterface myInterface\n{\n    function myFunction1();\n    function 
myFunction2($x); // NOTE Imenu not working either\n}\n"
-   "Imenu in interface class with arguments in one method"
-   (should (equal (phps-mode-lex-analyzer--get-imenu) '(("myInterface" 
("myFunction1" . 44) ("myFunction2" . 72))))))
-
-  (phps-mode-test--with-buffer
-   "<?php\n\nnamespace MyNamespace;\n\nfunction aFunction() {\n    /**\n     * 
With some contents\n     */\n}\n\nclass MyClass\n{\n\n    /**\n     *\n     
*/\n    public function __construct()\n    {\n        if ($test) {\n        }\n 
   }\n\n    /**\n     *\n     */\n    public function myFunction1()\n    {\n    
    $this->addMessage(\"My random {$message} here\" . ($random > 1 ? \"A\" : 
\"\") . \" was here.\");\n    }\n    \n    /**\n     *\n     */\n    public 
function myFunction2()\n [...]
-   "Imenu with double quoted string with variable inside it and concatenated 
string"
-   (should (equal (phps-mode-lex-analyzer--get-imenu) '(("MyNamespace" 
("aFunction" . 41) ("MyClass" ("__construct" . 160) ("myFunction1" . 261) 
("myFunction2" . 433) ("myFunction3" . 513) ("myFunction4" . 583)))))))
-
-  (phps-mode-test--with-buffer
-  "<?php\n\nnamespace MyNamespaceA\n{\n    function aFunctionA() {\n        
/**\n         * With some contents\n         */\n    }\n    class MyClass\n    
{\n\n        /**\n         *\n         */\n        public function 
__construct()\n        {\n            if ($test) {\n            }\n        
}\n\n        /**\n         *\n         */\n        public function 
myFunction1()\n        {\n            $this->addMessage(\"My random {$message} 
here\" . ($random > 1 ? \"A\" : \"\") . \" was he [...]
-  "Imenu with double quoted string with variable inside it and concatenated 
string in two namespaces"
-  (should (equal (phps-mode-lex-analyzer--get-imenu) '(("MyNamespaceA" 
("aFunctionA" . 46) ("MyClass" ("__construct" . 205) ("myFunction1" . 338) 
("myFunction2" . 542) ("myFunction3" . 646) ("myFunction4" . 740))) 
("aFunctionB" . 807) ("MyClass" ("__construct" . 925) ("myFunction1" . 1058) 
("myFunction2" . 1262) ("myFunction3" . 1366) ("myFunction4" . 1460))))))
-
-  )
-
 (defun phps-mode-test-lex-analyzer--get-moved-imenu ()
   "Test for moving imenu index."
 
@@ -1654,7 +1559,6 @@
   (phps-mode-test-lex-analyzer--get-lines-indent-psr-2)
   (phps-mode-test-lex-analyzer--get-lines-indent)
   (phps-mode-test-lex-analyzer--indent-line)
-  (phps-mode-test-lex-analyzer--imenu)
   (phps-mode-test-lex-analyzer--get-moved-imenu)
   (phps-mode-test-lex-analyzer--comment-uncomment-region))
 

Reply via email to