Skip to content

Commit c63db83

Browse files
kermorgantzonuexe
authored andcommitted
buttercup first tests with linked changes in phactor.el
add travis conf in order to run buttercup tests test phpactor installation test phpactor-get-working-dir (remove unused phpactor-working-dir variable) test phpactor--lisp-directory and add a fix for it
1 parent 38f1fc7 commit c63db83

File tree

4 files changed

+89
-14
lines changed

4 files changed

+89
-14
lines changed

.travis.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# matrix:
2+
# include:
3+
# - language: emacs-lisp
4+
# sudo: no
5+
# env:
6+
# - EVM_EMACS=emacs-25.1-travis
7+
# before_install:
8+
# - curl -fsSkL https://gist.github.com/rejeep/ebcd57c3af83b049833b/raw > travis.sh && source ./travis.sh
9+
# - evm install "$EVM_EMACS" --use --skip
10+
# install:
11+
# - cask --debug --verbose
12+
# script:
13+
# - cask exec buttercup -L . -p phpactor-install-or-update
14+
# - cd ~/.emacs.d/phpactor && composer install --no-dev
15+
# - cd -
16+
17+
# - language: php
18+
# php:
19+
# - 7.2
20+
# script:
21+
# - cd ~/.emacs.d/phpactor && composer install --no-dev
22+
23+
language: php
24+
php:
25+
- 7.1
26+
sudo: no
27+
env:
28+
- EVM_EMACS=emacs-25.1-travis
29+
before_install:
30+
- curl -fsSkL https://gist.github.com/rejeep/ebcd57c3af83b049833b/raw > travis.sh && source ./travis.sh
31+
- evm install "$EVM_EMACS" --use --skip
32+
install:
33+
- cask --debug --verbose
34+
script:
35+
- cask exec buttercup -L .
36+
# - cask exec buttercup -L . -p phpactor-install-or-update # running only this test prepares ./emacs.d/phpactor folder
37+
# - cd ~/.emacs.d/phpactor && composer install --no-dev
38+
# - cd - && cask exec buttercup -L .

Cask

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
(package "phpactor" "0.1.0" "Interface to Phpactor")
22
(source melpa)
3+
(source gnu)
34

45
(package-file "phpactor.el")
56
(package-file "company-phpactor.el")
67

78
(development
89
(depends-on "php-mode")
9-
(depends-on "auto-complete"))
10+
(depends-on "buttercup"))

phpactor.el

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -78,15 +78,6 @@
7878
#'(lambda (v) (if (consp v)
7979
(and (eq 'root (car v)) (stringp (cdr v)))
8080
(or (null v) (stringp v))))))
81-
;;;###autoload
82-
(progn
83-
(defvar phpactor-working-dir nil
84-
"Path to working directory for Phpactor.")
85-
(make-variable-buffer-local 'phpactor-working-dir)
86-
(put 'phpactor-executable 'safe-local-variable
87-
#'(lambda (v) (if (consp v)
88-
(and (eq 'root (car v)) (stringp (cdr v)))
89-
(or (null v) (stringp v))))))
9081

9182
(defvar phpactor--debug nil)
9283
(defvar phpactor-history-size 100)
@@ -105,7 +96,7 @@
10596
lib-dir)
10697
(if (and byte-compiled-dir (file-directory-p byte-compiled-dir))
10798
(file-name-directory byte-compiled-dir)
108-
(setq lib-dir (locate-library "phpactor.el"))
99+
(setq lib-dir (file-name-directory (locate-library "phpactor.el")))
109100
(when (and lib-dir (file-directory-p lib-dir))
110101
(file-name-directory lib-dir))))
111102
"Path to phpactor.el installed directory.
@@ -156,14 +147,15 @@ of GitHub.")
156147
(php-runtime-quote-string (concat directory file))
157148
(php-runtime-quote-string (concat phpactor-install-directory file)))
158149
do (php-runtime-expr code))
159-
(composer nil "install" "--no-dev")))
150+
(composer nil "install" "--no-dev")
151+
;; (call-process "composer" nil t nil "install" "--no-dev")
152+
))
160153
(defalias 'phpactor-update #'phpactor-install-or-update)
161154

162155
(defun phpactor-get-working-dir ()
163156
"Return working directory of Phpactor."
164157
(directory-file-name
165-
(expand-file-name
166-
(or phpactor-working-dir (php-project-get-root-dir)))))
158+
(expand-file-name (php-project-get-root-dir))))
167159

168160
(defun phpactor--expand-local-file-name (name)
169161
"Expand file name by `NAME'."

tests/e2e/test-sanity.el

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
(require 'phpactor)
2+
3+
(defun buffer-string* (buffer)
4+
(with-current-buffer buffer
5+
(buffer-substring-no-properties (point-min) (point-max) )))
6+
7+
(describe "var: `phpactor-history-size'"
8+
(it "should have default value"
9+
(expect phpactor-history-size :to-be 100)
10+
))
11+
12+
(describe "var: `phpactor-install-directory'"
13+
(it "should have some value"
14+
(display-warning 'buttercup (format "phpactor install folder is : %s" phpactor-install-directory))
15+
(expect phpactor-install-directory :not :to-be nil)
16+
))
17+
18+
(describe ": `phpactor--lisp-directory'" ;; I prefer having a test as I'm not that really fine with it being nil
19+
(it "should have some value"
20+
(display-warning 'buttercup (format "phpactor lisp folder is : %s" phpactor--lisp-directory))
21+
(expect phpactor--lisp-directory :not :to-be nil)
22+
))
23+
24+
(describe "defun: `phpactor-install-or-update'"
25+
(it "should find phpactor installed under phpactor-install-directory :"
26+
(let ((timeout-duration 300))
27+
(phpactor-install-or-update)
28+
(with-timeout
29+
(timeout-duration (display-warning 'buttercup (format "Error : timeout waiting %s seconds for composer install to finish" timeout-duration)))
30+
(while (not (file-exists-p (f-join phpactor-install-directory "vendor/bin/phpactor")))
31+
(sleep-for 1)))
32+
(expect (phpactor-find-executable) :to-equal (f-join phpactor-install-directory "vendor/bin/phpactor"))
33+
)))
34+
35+
(describe "defun: `phpactor-get-working-dir'"
36+
(it "should rely on php-project"
37+
(spy-on 'php-project-get-root-dir :and-call-through)
38+
;; (display-warning 'buttercup (format "phpactor-working-dir is : %s" phpactor-working-dir))
39+
(with-current-buffer (find-file "tests/src/Book.php")
40+
;; (message "phpactor-working-dir is : %s" (php-project-get-root-dir))
41+
(phpactor-get-working-dir)
42+
(expect 'php-project-get-root-dir :to-have-been-called)
43+
)
44+
))

0 commit comments

Comments
 (0)