-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from nlamirault/develop
Release 0.9.0
- Loading branch information
Showing
7 changed files
with
89 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,14 +4,14 @@ | |
;; Eric Hansen <[email protected]> | ||
;; | ||
;; URL: https://github.com/nlamirault/phpunit.el | ||
;; Version: 0.8.0 | ||
;; Version: 0.9.0 | ||
;; Keywords: php, tests, phpunit | ||
|
||
;; Package-Requires: ((s "1.9.0") (f "0.16.0") (pkg-info "0.5") (emacs "24.3")) | ||
;; Package-Requires: ((s "1.9.0") (f "0.16.0") (pkg-info "0.5") (cl-lib "0.5") (emacs "24.3")) | ||
|
||
;;; License: | ||
|
||
;; Copyright (C) 2014, 2015 Nicolas Lamirault <[email protected]> | ||
;; Copyright (C) 2014, 2015, 2016 Nicolas Lamirault <[email protected]> | ||
|
||
;; This program is free software; you can redistribute it and/or | ||
;; modify it under the terms of the GNU General Public License | ||
|
@@ -41,6 +41,7 @@ | |
|
||
;;; Code: | ||
|
||
(require 'cl-lib) | ||
(require 's) | ||
(require 'f) | ||
|
||
|
@@ -78,9 +79,9 @@ | |
:type 'boolean | ||
:group 'phpunit) | ||
|
||
(defcustom phpunit-configuration-file "phpunit.xml" | ||
(defcustom phpunit-configuration-file nil | ||
"The PHPUnit configuration file." | ||
:type 'string | ||
:type '(choice string nil) | ||
:group 'phpunit) | ||
|
||
(defconst php-beginning-of-defun-regexp | ||
|
@@ -118,26 +119,30 @@ | |
;; "vendor/bin/phpunit")) | ||
(unless phpunit-executable | ||
(setq phpunit-executable phpunit-program)) | ||
(s-concat phpunit-executable " -c " | ||
(phpunit-get-root-directory) | ||
phpunit-configuration-file | ||
args) | ||
) | ||
) | ||
|
||
(defun phpunit-get-root-directory() | ||
(s-concat phpunit-executable | ||
(if phpunit-configuration-file | ||
(s-concat " -c " phpunit-configuration-file) | ||
"") | ||
" " | ||
args))) | ||
|
||
(defun phpunit-get-root-directory () | ||
"Return the root directory to run tests." | ||
;; The function doesn't detect the root directory when used with | ||
;; tramp mode. In that case, the phpunit-root-directory variable can | ||
;; be set which takes precedence | ||
(if (boundp 'phpunit-root-directory) | ||
phpunit-root-directory | ||
(let ((filename (buffer-file-name))) | ||
(when filename | ||
(file-truename (or (locate-dominating-file filename phpunit-configuration-file) | ||
"./")))))) | ||
|
||
|
||
(let ((filename (buffer-file-name)) path) | ||
(cond | ||
((null filename) default-directory) | ||
(phpunit-configuration-file | ||
(file-truename (locate-dominating-file filename phpunit-configuration-file))) | ||
(:else | ||
(cl-loop for file in '("phpunit.xml" "phpunit.xml.dist" ".git" "composer.json") | ||
do (setq path (locate-dominating-file filename file)) | ||
if path return (file-truename path) | ||
finally return (file-truename "./"))))))) | ||
|
||
(defun phpunit-get-current-class (&optional class-or-path) | ||
"Return the canonical unit test class name associated with the current class or buffer." | ||
|
@@ -178,7 +183,9 @@ | |
(concat column-setting-command command-separator phpunit-command))) | ||
|
||
(defun phpunit-run (args) | ||
(compile (phpunit-get-compile-command args))) | ||
"Execute phpunit command with `ARGS'." | ||
(let ((default-directory (phpunit-get-root-directory))) | ||
(compile (phpunit-get-compile-command args)))) | ||
|
||
|
||
;; API | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
;;; phpunit-test.el --- Tests for phpunit.el | ||
|
||
;; Copyright (C) Nicolas Lamirault <[email protected]> | ||
;; Copyright (C) 2014, 2015, 2016 Nicolas Lamirault <[email protected]> | ||
|
||
;;; Commentary: | ||
|
||
|
@@ -31,11 +31,13 @@ | |
|
||
|
||
(defun phpunit-command (&rest arg) | ||
;;(apply 's-concat "phpunit -c " "phpunit.xml" arg)) | ||
(let ((composer-dir (s-concat (concat (getenv "HOME") "/") ".composer"))) | ||
(let ((composer-dir (s-concat (concat (getenv "HOME") "/") ".composer")) | ||
(conf (if phpunit-configuration-file | ||
(s-concat "-c " phpunit-configuration-file " ") | ||
""))) | ||
(if (f-dir? composer-dir) | ||
(apply 's-concat composer-dir "/vendor/bin/phpunit -c " "phpunit.xml" arg) | ||
(apply 's-concat "./vendor/bin/phpunit -c " "phpunit.xml" arg)))) | ||
(apply 's-concat composer-dir "/vendor/bin/phpunit " conf arg) | ||
(apply 's-concat "./vendor/bin/phpunit " conf arg)))) | ||
|
||
|
||
(ert-deftest test-phpunit-get-class-from-file-path() | ||
|
@@ -54,11 +56,25 @@ | |
(phpunit-get-current-class "PhpUnitTest")))) | ||
|
||
|
||
;; Using configuration file | ||
|
||
(ert-deftest test-phpunit-with-configuration-file () | ||
:tags '(configuration-file) | ||
(with-test-sandbox | ||
(let ((phpunit-configuration-file "phpunit.xml")) | ||
(should (s-contains? "-c phpunit.xml" | ||
(phpunit-get-program (phpunit-arguments ""))))))) | ||
|
||
(ert-deftest test-phpunit-without-configuration-file () | ||
:tags '(configuration-file) | ||
(with-test-sandbox | ||
(should-not (s-contains? "-c phpunit.xml" | ||
(phpunit-get-program (phpunit-arguments "")))))) | ||
|
||
;; Arguments | ||
|
||
(ert-deftest test-phpunit-get-program-without-args () | ||
:tags '(current arguments) | ||
:tags '(arguments) | ||
(with-test-sandbox | ||
(should (string= (phpunit-command) | ||
(phpunit-get-program (phpunit-arguments "")))))) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
;;; phpunit-version-test.el --- Tests for version information | ||
|
||
;; Copyright (C) Nicolas Lamirault <[email protected]> | ||
;; Copyright (C) 2014, 2015, 2016 Nicolas Lamirault <[email protected]> | ||
|
||
;;; Commentary: | ||
|
||
|
@@ -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.8.0" cask-version)))) | ||
(should (string= "0.9.0" cask-version)))) | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
;; test-helper.el --- Test helpers for Phpunit.el | ||
|
||
;; Copyright (C) Nicolas Lamirault <[email protected]> | ||
;; Copyright (C) 2014, 2015, 2016 Nicolas Lamirault <[email protected]> | ||
|
||
;; Author: Nicolas Lamirault <[email protected]> | ||
;; Homepage: https://github.com/nlamirault/phpunit.el | ||
|