Skip to content

Commit

Permalink
tests: Add CakePHP v4.5 tests
Browse files Browse the repository at this point in the history
  • Loading branch information
PROFeNoM committed Apr 9, 2024
1 parent e763be0 commit 3cf3c5f
Show file tree
Hide file tree
Showing 100 changed files with 3,906 additions and 4 deletions.
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -748,6 +748,7 @@ TEST_INTEGRATIONS_74 := \

TEST_WEB_74 := \
test_metrics \
test_web_cakephp_45 \
test_web_cakephp_310 \
test_web_codeigniter_22 \
test_web_codeigniter_31 \
Expand Down Expand Up @@ -811,6 +812,7 @@ TEST_INTEGRATIONS_80 := \

TEST_WEB_80 := \
test_metrics \
test_web_cakephp_45 \
test_web_codeigniter_22 \
test_web_codeigniter_31 \
test_web_drupal_95 \
Expand Down Expand Up @@ -859,6 +861,7 @@ TEST_INTEGRATIONS_81 := \

TEST_WEB_81 := \
test_metrics \
test_web_cakephp_45 \
test_web_codeigniter_22 \
test_web_codeigniter_31 \
test_web_drupal_95 \
Expand Down Expand Up @@ -910,6 +913,7 @@ TEST_INTEGRATIONS_82 := \

TEST_WEB_82 := \
test_metrics \
test_web_cakephp_45 \
test_web_codeigniter_22 \
test_web_codeigniter_31 \
test_web_drupal_95 \
Expand Down Expand Up @@ -965,6 +969,7 @@ TEST_INTEGRATIONS_83 := \

TEST_WEB_83 := \
test_metrics \
test_web_cakephp_45 \
test_web_codeigniter_22 \
test_web_codeigniter_31 \
test_web_drupal_95 \
Expand Down Expand Up @@ -1252,6 +1257,9 @@ test_web_cakephp_28: global_test_run_dependencies
test_web_cakephp_310: global_test_run_dependencies
$(call run_composer_with_retry,tests/Frameworks/CakePHP/Version_3_10,)
$(call run_tests_debug,--testsuite=cakephp-310-test)
test_web_cakephp_45: global_test_run_dependencies
$(call run_composer_with_retry,tests/Frameworks/CakePHP/Version_4_5,)
$(call run_tests_debug,--testsuite=cakephp-45-test)
test_web_codeigniter_22: global_test_run_dependencies
$(call run_tests_debug,--testsuite=codeigniter-22-test)
test_web_codeigniter_31: global_test_run_dependencies
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,16 @@ function (SpanData $span) use ($integration) {
function (HookData $renderHook) {
$renderHook->span();

// The next Cake\View\View::_getViewFileName call will happen from render and will return the filename
// of the given action template file with the extension (e.g., .ctp, .twig)
// The next Cake\View\View::_getViewFileName (v3) or Cake\View\View::_getTemplateFileName (v4+) call
// will happen from render and will return the filename of the given action template file with the
// extension (e.g., .ctp, .twig)
$methodName = version_compare(\Cake\Core\Configure::version(), '4.0.0', '>=') ?
'Cake\View\View::_getTemplateFileName' : 'Cake\View\View::_getViewFileName';
\DDTrace\install_hook(
'Cake\View\View::_getViewFileName',
$methodName,
null,
function (HookData $hook) use ($renderHook) {
$renderHook->data['viewFileName'] = $hook->returned;

\DDTrace\remove_hook($hook->id);
}
);
Expand Down
23 changes: 23 additions & 0 deletions tests/Frameworks/CakePHP/Version_4_5/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
; This file is for unifying the coding style for different editors and IDEs.
; More information at https://editorconfig.org

root = true

[*]
indent_style = space
indent_size = 4
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

[*.bat]
end_of_line = crlf

[*.yml]
indent_size = 2

[*.twig]
insert_final_newline = false

[Makefile]
indent_style = tab
36 changes: 36 additions & 0 deletions tests/Frameworks/CakePHP/Version_4_5/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Define the line ending behavior of the different file extensions
# Set default behavior, in case users don't have core.autocrlf set.
* text text=auto eol=lf

# Declare files that will always have CRLF line endings on checkout.
*.bat eol=crlf

# Declare files that will always have LF line endings on checkout.
*.pem eol=lf

# Denote all files that are truly binary and should not be modified.
*.png binary
*.jpg binary
*.jpeg binary
*.gif binary
*.webp binary
*.avif binary
*.ico binary
*.mo binary
*.pdf binary
*.xls binary
*.xlsx binary
*.phar binary
*.woff binary
*.woff2 binary
*.ttc binary
*.ttf binary
*.otf binary
*.eot binary
*.gz binary
*.bz2 binary
*.7z binary
*.zip binary
*.webm binary
*.mp4 binary
*.ogv binary
52 changes: 52 additions & 0 deletions tests/Frameworks/CakePHP/Version_4_5/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# CakePHP specific files #
##########################
/config/app_local.php
/config/.env
/logs/*
/tmp/*
/vendor/*

# OS generated files #
######################
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
# Icon must end with two \r
Icon
ehthumbs.db
Thumbs.db
.directory

# Tool specific files #
#######################
# PHPUnit
.phpunit.result.cache
tests.sqlite
# vim
*~
*.swp
*.swo
# sublime text & textmate
*.sublime-*
*.stTheme.cache
*.tmlanguage.cache
*.tmPreferences.cache
# Eclipse
.settings/*
# JetBrains, aka PHPStorm, IntelliJ IDEA
.idea/*
# NetBeans
nbproject/*
# Visual Studio Code
.vscode
# nova
.nova
# Sass preprocessor
.sass-cache/
# node
/node_modules/*
# yarn
yarn-debug.log
yarn-error.log
Expand Down
12 changes: 12 additions & 0 deletions tests/Frameworks/CakePHP/Version_4_5/.htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Uncomment the following to prevent the httpoxy vulnerability
# See: https://httpoxy.org/
#<IfModule mod_headers.c>
# RequestHeader unset Proxy
#</IfModule>

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^(\.well-known/.*)$ $1 [L]
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
53 changes: 53 additions & 0 deletions tests/Frameworks/CakePHP/Version_4_5/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# CakePHP Application Skeleton

![Build Status](https://github.com/cakephp/app/actions/workflows/ci.yml/badge.svg?branch=master)
[![Total Downloads](https://img.shields.io/packagist/dt/cakephp/app.svg?style=flat-square)](https://packagist.org/packages/cakephp/app)
[![PHPStan](https://img.shields.io/badge/PHPStan-level%207-brightgreen.svg?style=flat-square)](https://github.com/phpstan/phpstan)

A skeleton for creating applications with [CakePHP](https://cakephp.org) 4.x.

The framework source code can be found here: [cakephp/cakephp](https://github.com/cakephp/cakephp).

## Installation

1. Download [Composer](https://getcomposer.org/doc/00-intro.md) or update `composer self-update`.
2. Run `php composer.phar create-project --prefer-dist cakephp/app [app_name]`.

If Composer is installed globally, run

```bash
composer create-project --prefer-dist cakephp/app
```

In case you want to use a custom app dir name (e.g. `/myapp/`):

```bash
composer create-project --prefer-dist cakephp/app myapp
```

You can now either use your machine's webserver to view the default home page, or start
up the built-in webserver with:

```bash
bin/cake server -p 8765
```

Then visit `http://localhost:8765` to see the welcome page.

## Update

Since this skeleton is a starting point for your application and various files
would have been modified as per your needs, there isn't a way to provide
automated upgrades, so you have to do any updates manually.

## Configuration

Read and edit the environment specific `config/app_local.php` and set up the
`'Datasources'` and any other configuration relevant for your application.
Other environment agnostic settings can be changed in `config/app.php`.

## Layout

The app skeleton uses [Milligram](https://milligram.io/) (v1.3) minimalist CSS
framework by default. You can, however, replace it with any other library or
custom styles.
47 changes: 47 additions & 0 deletions tests/Frameworks/CakePHP/Version_4_5/bin/bash_completion.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#
# Bash completion file for CakePHP console.
# Copy this file to a file named `cake` under `/etc/bash_completion.d/`.
# For more info check https://book.cakephp.org/4/en/console-commands/completion.html#how-to-enable-bash-autocompletion-for-the-cakephp-console
#

_cake()
{
local cur prev opts cake
COMPREPLY=()
cake="${COMP_WORDS[0]}"
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"

if [[ "$cur" == -* ]] ; then
if [[ ${COMP_CWORD} = 1 ]] ; then
opts=$(${cake} completion options)
elif [[ ${COMP_CWORD} = 2 ]] ; then
opts=$(${cake} completion options "${COMP_WORDS[1]}")
else
opts=$(${cake} completion options "${COMP_WORDS[1]}" "${COMP_WORDS[2]}")
fi

COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
fi

if [[ ${COMP_CWORD} = 1 ]] ; then
opts=$(${cake} completion commands)
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
fi

if [[ ${COMP_CWORD} = 2 ]] ; then
opts=$(${cake} completion subcommands $prev)
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
if [[ $COMPREPLY = "" ]] ; then
_filedir
return 0
fi
return 0
fi

return 0
}

complete -F _cake cake bin/cake
75 changes: 75 additions & 0 deletions tests/Frameworks/CakePHP/Version_4_5/bin/cake
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#!/usr/bin/env sh
################################################################################
#
# Cake is a shell script for invoking CakePHP shell commands
#
# CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
# Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
#
# Licensed under The MIT License
# For full copyright and license information, please see the LICENSE.txt
# Redistributions of files must retain the above copyright notice.
#
# @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
# @link https://cakephp.org CakePHP(tm) Project
# @since 1.2.0
# @license https://opensource.org/licenses/mit-license.php MIT License
#
################################################################################

# Canonicalize by following every symlink of the given name recursively
canonicalize() {
NAME="$1"
if [ -f "$NAME" ]
then
DIR=$(dirname -- "$NAME")
NAME=$(cd -P "$DIR" > /dev/null && pwd -P)/$(basename -- "$NAME")
fi
while [ -h "$NAME" ]; do
DIR=$(dirname -- "$NAME")
SYM=$(readlink "$NAME")
NAME=$(cd "$DIR" > /dev/null && cd "$(dirname -- "$SYM")" > /dev/null && pwd)/$(basename -- "$SYM")
done
echo "$NAME"
}

# Find a CLI version of PHP
findCliPhp() {
for TESTEXEC in php php-cli /usr/local/bin/php
do
SAPI=$(echo "<?= PHP_SAPI ?>" | $TESTEXEC 2>/dev/null)
if [ "$SAPI" = "cli" ]
then
echo $TESTEXEC
return
fi
done
echo "Failed to find a CLI version of PHP; falling back to system standard php executable" >&2
echo "php";
}

# If current path is a symlink, resolve to real path
realname="$0"
if [ -L "$realname" ]
then
realname=$(readlink -f "$0")
fi

CONSOLE=$(dirname -- "$(canonicalize "$realname")")
APP=$(dirname "$CONSOLE")

# If your CLI PHP is somewhere that this doesn't find, you can define a PHP environment
# variable with the correct path in it.
if [ -z "$PHP" ]
then
PHP=$(findCliPhp)
fi

if [ "$(basename "$realname")" != 'cake' ]
then
exec "$PHP" "$CONSOLE"/cake.php "$(basename "$realname")" "$@"
else
exec "$PHP" "$CONSOLE"/cake.php "$@"
fi

exit
Loading

0 comments on commit 3cf3c5f

Please sign in to comment.