Skip to content

Commit

Permalink
Merge pull request #2 from markhuot/devcontainer
Browse files Browse the repository at this point in the history
Devcontainer
  • Loading branch information
markhuot authored Nov 18, 2023
2 parents e0582b1 + ea09ba0 commit 4b51f19
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 19 deletions.
3 changes: 3 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM mcr.microsoft.com/devcontainers/php:8.2
RUN apt update && apt install -y libicu-dev libz-dev libzip-dev vim mariadb-client
RUN docker-php-ext-install bcmath intl zip pdo_mysql
15 changes: 15 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"dockerComposeFile": "docker-compose.yml",
"service": "php",
"workspaceFolder": "/workspaces/craft-pest-core",
"customizations": {
"vscode": {
"extensions": [
"m1guelpf.better-pest",
"bmewburn.vscode-intelephense-client",
"whatwedo.twig"
]
}
},
"postCreateCommand": "composer install && ./bin/post-clone.sh && cp .env.example .env && echo 'CRAFT_DB_SERVER=mysql' >> .env && echo 'CRAFT_DB_DATABASE=pest' >> .env && echo 'CRAFT_DB_PASSWORD=root' >> .env && php craft install --username=admin [email protected] --password=secret --siteName=pest --siteUrl=http://localhost:8080 --language=en-US && ./bin/post-install.sh"
}
34 changes: 34 additions & 0 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
version: '3.7'

services:
php:
build:
context: ./
dockerfile: Dockerfile
environment:
- CRAFT_DB_DRIVER=mysql
- CRAFT_DB_SERVER=mysql
- CRAFT_DB_PORT=3306
- CRAFT_DB_DATABASE=pest
- CRAFT_DB_USER=root
- CRAFT_DB_PASSWORD=root
- CRAFT_DB_SCHEMA=public
- CRAFT_DB_TABLE_PREFIX=
- CRAFT_APP_ID=CraftCMS--0f6629c1-49b5-4f13-a492-0e0f81063911
- CRAFT_ENVIRONMENT=dev
- CRAFT_SECURITY_KEY=2UK5H8fUIgnTBSWVMnMXFlraQG8tLjC5
- CRAFT_DEV_MODE=true
mysql:
image: jbergstroem/mariadb-alpine:latest
cap_add:
- SYS_NICE # CAP_SYS_NICE
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: pest
init: true
expose:
- "3306"
volumes:
- db-data:/var/lib/mysql
volumes:
db-data:
23 changes: 8 additions & 15 deletions bin/post-clone.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,14 @@ if ! grep -q "CRAFT_RUN_QUEUE_AUTOMATICALLY=false" .env.example; then
echo "" >> .env
fi

if [ ! -f "config/app.php" ]; then
mkdir -p config
echo "<?php return [
'components' => [
'queue' => [
'class' => \yii\queue\sync\Queue::class,
'handle' => true, // if tasks should be executed immediately
],
],
'bootstrap' => [
function (\$app) {
(new \\markhuot\\craftpest\\Pest)->bootstrap(\$app);
},
]
];" > config/app.php
if ! grep -q "CRAFT_TEMPLATES_PATH=./tests/templates" .env.example; then
echo "" >> .env
echo "CRAFT_TEMPLATES_PATH=./tests/templates" >> .env.example
echo "" >> .env
fi

if [ ! -d "config" ]; then
cp -r stubs/config ./
fi

if [ ! -d "web" ]; then
Expand Down
1 change: 0 additions & 1 deletion bin/post-install.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/bin/bash

php craft plugin/install keystone
php ./bin/create-default-fs.php > /dev/null 2>&1
9 changes: 9 additions & 0 deletions docs/making-requests.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,15 @@ $this->http('post', '/comments')
->assertOk();
```

## postJson(string $uri, array $body = array ())
Similar to `->post()`, while adding aJSON `content-type` and `accept` headers.
```php
$this->postJson('/comments', [
'author' => '...',
'body' => '...',
])->assertOk();
```

## action(string $action, array $body = array ())
Maes a `POST` request to Craft with the `action` param filled in to the
passed value.
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/console/PestController.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ function actionInit() {
* Do the install
*/
protected function runInit() {
if (file_exists(CRAFT_BASE_PATH . '/phpunit.xml') && !$this->force) {
echo 'A phpunit.xml file already exists in this project. If you want to replace the existing testing infrastructure re-run this command with the `--force` flag.'."\n";
if (file_exists(CRAFT_BASE_PATH . '/phpunit.xml')) {
return;
}

if (!is_dir(CRAFT_BASE_PATH . '/tests')) {
Expand Down

0 comments on commit 4b51f19

Please sign in to comment.