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

Add Zend Framework v1.21 integration test #1944

Merged
merged 4 commits into from
Mar 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
9 changes: 7 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -733,6 +733,7 @@ TEST_WEB_80 := \
test_web_symfony_52 \
test_web_wordpress_59 \
test_web_yii_2 \
test_web_zend_1_21 \
test_web_custom

TEST_INTEGRATIONS_81 := \
Expand All @@ -757,7 +758,8 @@ TEST_WEB_81 := \
test_web_slim_4 \
test_web_symfony_52 \
test_web_wordpress_59 \
test_web_custom
test_web_custom \
test_web_zend_1_21
# test_web_yii_2 \

TEST_INTEGRATIONS_82 := \
Expand Down Expand Up @@ -785,7 +787,8 @@ TEST_WEB_82 := \
test_web_symfony_52 \
test_web_symfony_62 \
test_web_wordpress_59 \
test_web_custom
test_web_custom \
test_web_zend_1_21
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add it for 8.0 and 8.1 too, or does that pose problems?

# test_web_yii_2 \

FILTER := .
Expand Down Expand Up @@ -1015,6 +1018,8 @@ test_web_nette_30: global_test_run_dependencies
$(call run_tests,tests/Integrations/Nette/V3_0)
test_web_zend_1: global_test_run_dependencies
$(call run_tests,tests/Integrations/ZendFramework/V1)
test_web_zend_1_21: global_test_run_dependencies
$(call run_tests,tests/Integrations/ZendFramework/V1_21)
test_web_custom: global_test_run_dependencies
$(COMPOSER) --working-dir=tests/Frameworks/Custom/Version_Autoloaded update
$(call run_tests,--testsuite=custom-framework-autoloading-test)
Expand Down
3 changes: 3 additions & 0 deletions ext/integrations/integrations.c
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,9 @@ void ddtrace_integrations_minit(void) {

DD_SET_UP_DEFERRED_LOADING_BY_METHOD(DDTRACE_INTEGRATION_YII, "yii\\di\\Container", "__construct",
"DDTrace\\Integrations\\Yii\\YiiIntegration");

DD_SET_UP_DEFERRED_LOADING_BY_METHOD(DDTRACE_INTEGRATION_ZENDFRAMEWORK, "Zend_Controller_Plugin_Broker", "preDispatch",
"DDTrace\\Integrations\\ZendFramework\\ZendFrameworkIntegration");
}

ddtrace_integration* ddtrace_get_integration_from_string(ddtrace_string integration) {
Expand Down
4 changes: 2 additions & 2 deletions src/Integrations/Integrations/IntegrationsLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,6 @@ public function __construct(array $integrations)

$this->integrations[MongoIntegration::NAME] =
'\DDTrace\Integrations\Mongo\MongoIntegration';
$this->integrations[ZendFrameworkIntegration::NAME] =
'\DDTrace\Integrations\ZendFramework\ZendFrameworkIntegration';

// For PHP 7.0+ use C level deferred integration loader
if (\PHP_MAJOR_VERSION < 7) {
Expand Down Expand Up @@ -113,6 +111,8 @@ public function __construct(array $integrations)
'\DDTrace\Integrations\Symfony\SymfonyIntegration';
$this->integrations[WordPressIntegration::NAME] =
'\DDTrace\Integrations\WordPress\WordPressIntegration';
$this->integrations[ZendFrameworkIntegration::NAME] =
'\DDTrace\Integrations\ZendFramework\ZendFrameworkIntegration';
}
}

Expand Down
1 change: 1 addition & 0 deletions tests/Frameworks/ZendFramework/Version_1_21/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
public/error.log
68 changes: 68 additions & 0 deletions tests/Frameworks/ZendFramework/Version_1_21/.zfproject.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?xml version="1.0"?>
<projectProfile type="default" version="1.21.4">
<projectDirectory>
<projectProfileFile filesystemName=".zfproject.xml"/>
<applicationDirectory classNamePrefix="Application_">
<configsDirectory>
<applicationConfigFile type="ini"/>
</configsDirectory>
<controllersDirectory>
<controllerFile controllerName="Index">
<actionMethod actionName="index"/>
</controllerFile>
<controllerFile controllerName="Error"/>
</controllersDirectory>
<formsDirectory enabled="false"/>
<layoutsDirectory enabled="false"/>
<modelsDirectory/>
<modulesDirectory enabled="false"/>
<servicesDirectory enabled="false"/>
<viewsDirectory>
<viewScriptsDirectory>
<viewControllerScriptsDirectory forControllerName="Index">
<viewScriptFile forActionName="index"/>
</viewControllerScriptsDirectory>
<viewControllerScriptsDirectory forControllerName="Error">
<viewScriptFile forActionName="error"/>
</viewControllerScriptsDirectory>
</viewScriptsDirectory>
<viewHelpersDirectory/>
<viewFiltersDirectory enabled="false"/>
</viewsDirectory>
<bootstrapFile filesystemName="Bootstrap.php"/>
</applicationDirectory>
<dataDirectory enabled="false">
<cacheDirectory enabled="false"/>
<searchIndexesDirectory enabled="false"/>
<localesDirectory enabled="false"/>
<logsDirectory enabled="false"/>
<sessionsDirectory enabled="false"/>
<uploadsDirectory enabled="false"/>
</dataDirectory>
<docsDirectory>
<file filesystemName="README.txt"/>
</docsDirectory>
<libraryDirectory>
<zfStandardLibraryDirectory enabled="false"/>
</libraryDirectory>
<publicDirectory>
<publicStylesheetsDirectory enabled="false"/>
<publicScriptsDirectory enabled="false"/>
<publicImagesDirectory enabled="false"/>
<publicIndexFile filesystemName="index.php"/>
<htaccessFile filesystemName=".htaccess"/>
</publicDirectory>
<projectProvidersDirectory enabled="false"/>
<temporaryDirectory enabled="false"/>
<testsDirectory>
<testPHPUnitConfigFile filesystemName="phpunit.xml"/>
<testPHPUnitBootstrapFile filesystemName="bootstrap.php"/>
<testApplicationDirectory>
<testApplicationControllerDirectory>
<testApplicationControllerFile forControllerName="Index"/>
</testApplicationControllerDirectory>
</testApplicationDirectory>
<testLibraryDirectory/>
</testsDirectory>
</projectDirectory>
</projectProfile>
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
protected function _initRoutes()
{
$router = Zend_Controller_Front::getInstance()->getRouter();
$router->addRoute(
'my_simple_view_route',
new Zend_Controller_Router_Route(
'simple_view',
[
'controller' => 'simple',
'action' => 'view'
])
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[production]
phpSettings.display_startup_errors = 0
phpSettings.display_errors = 0
includePaths.library = APPLICATION_PATH "/../library"
bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
bootstrap.class = "Bootstrap"
appnamespace = "Application"
resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
resources.frontController.params.displayExceptions = 0

[staging : production]

[testing : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1

[development : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
resources.frontController.params.displayExceptions = 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?php

class ErrorController extends Zend_Controller_Action
{
public function indexAction()
{
throw new \Exception('Controller error');
}

public function errorAction()
{
$errors = $this->_getParam('error_handler');

if (!$errors || !$errors instanceof ArrayObject) {
$this->view->message = 'You have reached the error page';
return;
}

switch ($errors->type) {
case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ROUTE:
case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER:
case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION:
// 404 error -- controller or action not found
$this->getResponse()->setHttpResponseCode(404);
$priority = Zend_Log::NOTICE;
$this->view->message = 'Page not found';
break;
default:
// application error
$this->getResponse()->setHttpResponseCode(500);
$priority = Zend_Log::CRIT;
$this->view->message = 'Application error';
break;
}

// Log exception, if logger available
if ($log = $this->getLog()) {
$log->log($this->view->message, $priority, $errors->exception);
$log->log('Request Parameters', $priority, $errors->request->getParams());
}

// conditionally display exceptions
if ($this->getInvokeArg('displayExceptions') == true) {
$this->view->exception = $errors->exception;
}

$this->view->request = $errors->request;
}

public function getLog()
{
$bootstrap = $this->getInvokeArg('bootstrap');
if (!$bootstrap->hasResource('Log')) {
return false;
}
$log = $bootstrap->getResource('Log');
return $log;
}


}

Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

class IndexController extends Zend_Controller_Action
{

public function init()
{
/* Initialize action controller here */
}

public function indexAction()
{
// action body
}


}

Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

class SimpleController extends Zend_Controller_Action
{
public function indexAction()
{
// Don't auto render this action
$this->_helper->viewRenderer->setNoRender();
echo 'This is a string.';
}

public function viewAction()
{
// Empty
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Zend Framework Default Application</title>
</head>
<body>
<h1>An error occurred</h1>
<h2><?php echo $this->message ?></h2>

<?php if (isset($this->exception)): ?>

<h3>Exception information:</h3>
<p>
<b>Message:</b> <?php echo $this->exception->getMessage() ?>
</p>

<h3>Stack trace:</h3>
<pre><?php echo $this->exception->getTraceAsString() ?>
</pre>

<h3>Request Parameters:</h3>
<pre><?php echo $this->escape(var_export($this->request->getParams(), true)) ?>
</pre>

<?php endif ?>

</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<style>
a:link,
a:visited
{
color: #0398CA;
}

span#zf-name
{
color: #91BE3F;
}

div#welcome
{
color: #FFFFFF;
background-image: url(http://framework.zend.com/images/bkg_header.jpg);
width: 600px;
height: 400px;
border: 2px solid #444444;
overflow: hidden;
text-align: center;
}

div#more-information
{
background-image: url(http://framework.zend.com/images/bkg_body-bottom.gif);
height: 100%;
}
</style>
<div id="welcome">
<h1>Welcome to the <span id="zf-name">Zend Framework!</span></h1>

<h3>This is your project's main page</h3>

<div id="more-information">
<p><img src="http://framework.zend.com/images/PoweredBy_ZF_4LightBG.png" /></p>
<p>
Helpful Links: <br />
<a href="http://framework.zend.com/">Zend Framework Website</a> |
<a href="http://framework.zend.com/manual/en/">Zend Framework Manual</a>
</p>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<h1>This is a simple view</h1>
Loading