Skip to content

Commit c373e03

Browse files
committed
Fix testcase for php-project-root and set default-directory
fixes #568
1 parent 5a5b907 commit c373e03

File tree

7 files changed

+9
-2
lines changed

7 files changed

+9
-2
lines changed

tests/php-mode-test.el

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,8 @@ file name and check that the faces of the fonts in the buffer match."
134134
`(with-temp-buffer
135135
(setq php-mode-enable-backup-style-variables nil)
136136
(insert-file-contents (expand-file-name ,file php-mode-test-dir))
137+
(setq default-directory
138+
(expand-file-name ".." (expand-file-name ,file php-mode-test-dir)))
137139
(php-mode)
138140
,(if (fboundp 'font-lock-ensure)
139141
'(font-lock-ensure)
@@ -635,8 +637,12 @@ as a keyword."
635637
(should (eq 0 (- (point-max) (point-min))))))
636638

637639
(ert-deftest php-project-root ()
638-
(should (string= (abbreviate-file-name default-directory)
639-
(php-project-get-root-dir))))
640+
"Test for detection `php-project-root' by directory."
641+
(dolist (root (mapcar #'car php-project-available-root-files))
642+
(with-php-mode-test ("project/1/src/functions.php")
643+
(let ((php-project-root root))
644+
(should (string= (expand-file-name "project/1/" php-mode-test-dir)
645+
(expand-file-name (php-project-get-root-dir))))))))
640646

641647
(defun php-mode-test-in-function-p (&optional pos)
642648
"Determine whether POS is inside a function.

tests/project/1/.editorconfig

Whitespace-only changes.

tests/project/1/.hg

Whitespace-only changes.

tests/project/1/.projectile

Whitespace-only changes.

tests/project/1/.svn

Whitespace-only changes.

tests/project/1/composer.json

Whitespace-only changes.

tests/project/1/src/functions.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<?php

0 commit comments

Comments
 (0)