Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support custom phpunit command #39

Merged
merged 2 commits into from
Dec 19, 2016

Conversation

zonuexe
Copy link
Collaborator

@zonuexe zonuexe commented Sep 14, 2016

ref #38

Usage

(setq-local phpunit-program "docker")
(setq-local phpunit-arg '("exec" "-it" "container" "phpunit")
;; or (setq-local phpunit-arg "exec -it container phpunit")

@CarwynNelson
Copy link

HI @zonuexe. Is there any chance that this could be merged in? This would help me (and I'm sure many more people) so much. I'm a bit of a noob at emacs-lisp so at the moment I'm running my tests through the command line manually.

Thanks :)

@zonuexe
Copy link
Collaborator Author

zonuexe commented Dec 19, 2016

@CarwynNelson
I do not have commit access right of this project.

@nlamirault
Can you merge this PR?

@nlamirault nlamirault merged commit 7f9c07c into nlamirault:develop Dec 19, 2016
@nlamirault
Copy link
Owner

Done. I create a new release (0.14.0)

@zonuexe zonuexe deleted the feature/custom-phpunit-command branch December 19, 2016 12:39
@zonuexe
Copy link
Collaborator Author

zonuexe commented Dec 19, 2016

@nlamirault thanks!

@CarwynNelson
Copy link

Hi @zonuexe

Sorry to be a bit of a bother. I'm quite new to emacs and emacs-lisp and was wondering if you could provide a little help?

The instructions in your pull request mention using setq-local to set the preferred phpunit command. I was just wondering if it is possible at all to set this on a per project basis? I've done some googling but I haven't managed to find anything so far.

Is it possible to have a dotfile, or something similar, in the root of a project with these setq-local commands for each project?

Thanks very much!

@zonuexe
Copy link
Collaborator Author

zonuexe commented Dec 20, 2016

@CarwynNelson

Is it possible to have a dotfile, or something similar, in the root of a project with these setq-local commands for each project?

Probably, you can do it by .dir-locals.el. See GNU Emacs Manual: Directory Variables.

Other way, you can set variables by php-mode-hook.

(defun your-php-mode-hook ()
  "Your PHP-mode hook."

  (when (and buffer-file-name (string-match "/your-awesome-project/" buffer-file-name))
    (setq-local phpunit-program "docker")
    (setq-local phpunit-arg '("exec" "-it" "container" "phpunit"))))

(add-hook 'php-mode-hook 'your-php-mode-hook)

@CarwynNelson
Copy link

CarwynNelson commented Dec 20, 2016

EDIT: I have upgraded to the latest version of emacs that I can get which is 26.0.50.2 - recompiled and reinstalled some plugins and restarted but I'm still getting the issue :(
EDIT EDIT: I have tried this on my other computer and it appears to be working. Looks like this is user error on my part so I'll have to do some digging. Thanks for all of your help @zonuexe!

Hi @zonuexe

Thanks for the reply, I really appreciate it!

I have tried your method of using a php-mode hook but that doesn't seem to work for me for some reason.

Here is the code I have added to my php.el (included in init.el)

(defun hyperion-in-docker ()
  "Run Hyperion tests in docker container"
  (when (and buffer-file-name (string-match "/hyperion/hyperion/") buffer-file-name))
  (setq-local phpunit-program "docker")
  (setq-local phpunit-arg '("exec" "-it" "hyperion_php_1" "phpunit")))

(add-hook 'php-mode-hook 'hyperion-in-docker)

But for some reason the phpunit command still runs the local install of phpunit:

-*- mode: compilation; default-directory: "~/development/hyperion/hyperion/" -*-
Compilation started at Tue Dec 20 09:37:13

stty cols 139; ./vendor/bin/phpunit 
Bunch of errors here because phpunit is not being run inside of the container.

Here is the output from emacs --version

GNU Emacs 24.5.1
Copyright (C) 2015 Free Software Foundation, Inc.
GNU Emacs comes with ABSOLUTELY NO WARRANTY.
You may redistribute copies of Emacs
under the terms of the GNU General Public License.
For more information about these matters, see the file named COPYING.

I have had a look and confirmed that the version of the phpunit script for emacs is indeed 0.14.0

;; URL: https://github.com/nlamirault/phpunit.el
;; Version: 0.14.0
;; Keywords: php, tests, phpunit

Do you have any suggestions as to what I might be doing incorrectly?

@CarwynNelson
Copy link

@zonuexe I managed to get it working! Thanks very much for all the help! I'll see if I can find the time to add this to the documentation for future emacs newcomers :)

@nlamirault
Copy link
Owner

@zonuexe do you want commit access right for this project ?

@zonuexe
Copy link
Collaborator Author

zonuexe commented Dec 21, 2016

@CarwynNelson I could not help you, but I am pleased that you succeeded in self-help!

@zonuexe
Copy link
Collaborator Author

zonuexe commented Dec 21, 2016

@nlamirault
Thanks for your propose! I have never cooperated with other people's project management, but I will continue to contribute to this project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants