Skip to content

Instantly share code, notes, and snippets.

@dmj
Created August 3, 2012 08:18
Show Gist options
  • Save dmj/3245746 to your computer and use it in GitHub Desktop.
Save dmj/3245746 to your computer and use it in GitHub Desktop.
Helper functions for eproject/phix-project
(defun dmaus/phix-project/jump-to-unit-test ()
(interactive)
(let ((project-root (eproject-root)))
(when project-root
(let ((unit-test-file
(expand-file-name
(concat (file-name-sans-extension (file-relative-name (buffer-file-name) (expand-file-name "src/php" project-root)))
"Test." (file-name-extension (buffer-file-name)))
(expand-file-name "src/tests/unit-tests/php" project-root))))
(switch-to-buffer (or (find-buffer-visiting unit-test-file)
(find-file-noselect unit-test-file)))))))
(defun dmaus/php-project/run-phpunit ()
(interactive)
(let ((project-root (eproject-root)))
(when project-root
(let ((phpunit-buffer (get-buffer-create "*PHPUNIT*")))
(display-buffer phpunit-buffer)
(with-current-buffer phpunit-buffer
(erase-buffer)
(cd project-root)
(call-process "phpunit" nil t t))))))
(define-key php-mode-map (kbd "C-c C-t") #'dmaus/php-project/run-phpunit)
(define-key php-mode-map (kbd "C-c C-j") #'dmaus/phix-project/jump-to-unit-test)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment