diff --git a/Makefile b/Makefile index da148e75..bb837709 100644 --- a/Makefile +++ b/Makefile @@ -37,6 +37,7 @@ dev: # for an example of using a script like this with the 'git bisect run' # command. test: clean all + touch tests/project/1/.git $(EMACS) -Q -batch -L . -l tests/php-mode-test.el -f ert-run-tests-batch-and-exit .PHONY: all autoloads clean test diff --git a/tests/php-mode-test.el b/tests/php-mode-test.el index 0ef1021d..431998fd 100644 --- a/tests/php-mode-test.el +++ b/tests/php-mode-test.el @@ -134,6 +134,8 @@ file name and check that the faces of the fonts in the buffer match." `(with-temp-buffer (setq php-mode-enable-backup-style-variables nil) (insert-file-contents (expand-file-name ,file php-mode-test-dir)) + (setq default-directory + (expand-file-name ".." (expand-file-name ,file php-mode-test-dir))) (php-mode) ,(if (fboundp 'font-lock-ensure) '(font-lock-ensure) @@ -635,8 +637,12 @@ as a keyword." (should (eq 0 (- (point-max) (point-min)))))) (ert-deftest php-project-root () - (should (string= (abbreviate-file-name default-directory) - (php-project-get-root-dir)))) + "Test for detection `php-project-root' by directory." + (dolist (root (mapcar #'car php-project-available-root-files)) + (with-php-mode-test ("project/1/src/functions.php") + (let ((php-project-root root)) + (should (string= (expand-file-name "project/1/" php-mode-test-dir) + (expand-file-name (php-project-get-root-dir)))))))) (defun php-mode-test-in-function-p (&optional pos) "Determine whether POS is inside a function. diff --git a/tests/project/1/.editorconfig b/tests/project/1/.editorconfig new file mode 100644 index 00000000..e69de29b diff --git a/tests/project/1/.hg b/tests/project/1/.hg new file mode 100644 index 00000000..e69de29b diff --git a/tests/project/1/.projectile b/tests/project/1/.projectile new file mode 100644 index 00000000..e69de29b diff --git a/tests/project/1/.svn b/tests/project/1/.svn new file mode 100644 index 00000000..e69de29b diff --git a/tests/project/1/composer.json b/tests/project/1/composer.json new file mode 100644 index 00000000..e69de29b diff --git a/tests/project/1/src/functions.php b/tests/project/1/src/functions.php new file mode 100644 index 00000000..b3d9bbc7 --- /dev/null +++ b/tests/project/1/src/functions.php @@ -0,0 +1 @@ +