Skip to content

Commit

Permalink
Merge pull request #26 from nlamirault/develop
Browse files Browse the repository at this point in the history
Release 0.11.0
  • Loading branch information
nlamirault committed Aug 8, 2016
2 parents 77686cc + 4c1a41b commit 88bbeb9
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 2 deletions.
4 changes: 4 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# phpunit.el ChangeLog

## Version 0.11.0 (08/08/2016)

- #PR25: Add phpunit-group (Thanks zonuexe)

## Version 0.10.0 (08/07/2016)

- #PR23: Better regexp using rx (Thanks zonuexe)
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ These functions are available :
* `phpunit-current-test`: launch unit tests for the current test in a class
* `phpunit-current-class`: launch unit tests for the current class
* `phpunit-current-project`: launch all unit tests
* `phpunit-group`: launch PHPUnit for group

You can create some key bindings with these commands:

Expand Down
50 changes: 49 additions & 1 deletion phpunit.el
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
;; Eric Hansen <hansen.c.eric@gmail.com>
;;
;; URL: https://github.com/nlamirault/phpunit.el
;; Version: 0.10.0
;; Version: 0.11.0
;; Keywords: php, tests, phpunit

;; Package-Requires: ((s "1.9.0") (f "0.16.0") (pkg-info "0.5") (cl-lib "0.5") (emacs "24.3"))
Expand Down Expand Up @@ -113,6 +113,8 @@
(interactive)
(add-to-list 'compilation-error-regexp-alist '("^\\(.+\\.php\\):\\([0-9]+\\)$" 1 2))))

(defvar phpunit-last-group-cache nil)

;; Commands
;; -----------

Expand Down Expand Up @@ -178,6 +180,34 @@
(when (re-search-backward php-beginning-of-defun-regexp nil t)
(match-string-no-properties 1))))

(defun phpunit--listing-groups ()
"Return list of @group.
https://phpunit.de/manual/current/en/appendixes.annotations.html#appendixes.annotations.group"
(let ((phpunit-output (phpunit--execute "--list-groups")))
(with-temp-buffer
(insert phpunit-output)
(goto-char (point-min))
(search-forward "Available test group")
(move-beginning-of-line 1)
(next-line)
(cl-loop
for line in (s-split "\n" (buffer-substring-no-properties (point) (point-max)))
if (s-starts-with? " - " line)
collect (s-chop-prefix " - " line)))))

(defun phpunit--get-last-group (path)
"Get last group cache by `PATH'."
(unless phpunit-last-group-cache
(setq phpunit-last-group-cache (make-hash-table :test 'equal)))
(gethash path phpunit-last-group-cache nil))

(defun phpunit--put-last-group (group path)
"Put last group `GROUP' cache by `PATH'."
(unless phpunit-last-group-cache
(setq phpunit-last-group-cache (make-hash-table :test 'equal)))
(puthash path group phpunit-last-group-cache))

(defun phpunit-arguments (args)
(let ((opts args))
(when phpunit-stop-on-error
Expand All @@ -196,6 +226,11 @@
(phpunit-command (phpunit-get-program (phpunit-arguments args))))
(concat column-setting-command command-separator phpunit-command)))

(defun phpunit--execute (args)
"Execute phpunit command with `ARGS'."
(let ((default-directory (phpunit-get-root-directory)))
(shell-command-to-string (phpunit-get-program (phpunit-arguments args)))))

(defun phpunit-run (args)
"Execute phpunit command with `ARGS'."
(let ((default-directory (phpunit-get-root-directory)))
Expand Down Expand Up @@ -228,6 +263,19 @@
(interactive)
(phpunit-run ""))

;;;###autoload
(defun phpunit-group (use-last-group &optional group)
"Launch PHPUnit for group."
(interactive "p")
(let* ((current-root-directory (phpunit-get-root-directory))
(last-group (phpunit--get-last-group current-root-directory)))
(when (called-interactively-p 'interactive)
(setq use-last-group (eq use-last-group 1))
(setq group (if (and use-last-group last-group)
last-group
(completing-read "PHPUnit @group: " (phpunit--listing-groups)))))
(phpunit-run (format "--group %s" group))
(phpunit--put-last-group group current-root-directory)))

(provide 'phpunit)
;;; phpunit.el ends here
2 changes: 1 addition & 1 deletion test/phpunit-version-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
;;(message "PHPUnit.el : %s" lib-version)
(message "PHPUnit.el Cask version: %s" cask-version)
;;(should (string= version (phpunit-mode-library-version)))))
(should (string= "0.10.0" cask-version))))
(should (string= "0.11.0" cask-version))))



Expand Down

0 comments on commit 88bbeb9

Please sign in to comment.