aboutsummaryrefslogtreecommitdiffstats
path: root/oni-php
diff options
context:
space:
mode:
authorGravatar Tom Willemse2025-04-16 12:31:24 -0700
committerGravatar Tom Willemse2025-04-16 12:31:24 -0700
commit13d38d77b8ec74456e30dd51a9823977bc0f2fde (patch)
tree86def734339eaeb90792628f38d413a8438da8bf /oni-php
parentf2cda9c07848bbb6b54348aaff157593aa52abde (diff)
downloademacs-config-13d38d77b8ec74456e30dd51a9823977bc0f2fde.tar.gz
emacs-config-13d38d77b8ec74456e30dd51a9823977bc0f2fde.zip
oni-php: Add auto-insert template for Laravel test files
Diffstat (limited to 'oni-php')
-rw-r--r--oni-php/oni-php.el27
1 files changed, 26 insertions, 1 deletions
diff --git a/oni-php/oni-php.el b/oni-php/oni-php.el
index 36394da..22e3ef5 100644
--- a/oni-php/oni-php.el
+++ b/oni-php/oni-php.el
@@ -4,7 +4,7 @@
;; Author: Tom Willemse <tom@ryuslash.org>
;; Keywords: local
-;; Version: 2025.0407.141956
+;; Version: 2025.0415.154414
;; Package-Requires: (php-mode oni-yasnippet oni-flycheck oni-company oni-hydra oni-smartparens ggtags fic-mode company-php rainbow-delimiters)
;; This program is free software; you can redistribute it and/or modify
@@ -205,5 +205,30 @@ Otherwise call FUNC with ARGS. This is meant as advice around
(with-eval-after-load 'grep
(add-to-list 'grep-files-aliases '("php" . "*.php *.inc *.module")))
+(with-eval-after-load 'autoinsert
+ (setf (map-elt auto-insert-alist (rx "Test.php" eos))
+ '(nil
+ "<?php\n"
+ "\n"
+ "declare(strict_types=1);\n"
+ "\n"
+ "namespace " (string-join (mapcar #'capitalize (cdr (split-string (directory-file-name (file-name-directory (file-relative-name buffer-file-name (project-root (project-current))))) "/"))) "\\") ";\n"
+ "\n"
+ "use Illuminate\\Foundation\\Testing\\RefreshDatabase;\n"
+ "use Illuminate\\Foundation\\Testing\\WithFaker;\n"
+ "use Tests\\TestCase;\n"
+ "\n"
+ "class " (file-name-sans-extension (file-name-nondirectory (buffer-file-name))) " extends TestCase\n"
+ "{\n"
+ > "use RefreshDatabase;\n"
+ > "use WithFaker;\n"
+ "\n"
+ > "/** @test */\n"
+ > "public function " (replace-regexp-in-string (rx whitespace) "_" (downcase (skeleton-read "Test function name: "))) "(): void\n"
+ "{" > "\n"
+ > _ "\n"
+ "}" > "\n"
+ "}")))
+
(provide 'oni-php)
;;; oni-php.el ends here