Permalink
Browse files

Making some initial adjustments and additions for Phar packaging.

  • Loading branch information...
1 parent 6db3e31 commit e441c20a2bb464f510ad939ef96d5df048a55224 @LouisLandry LouisLandry committed Jul 3, 2012
Showing with 181 additions and 1 deletion.
  1. +62 −0 libraries/import.stub.php
  2. +1 −1 libraries/joomla/http/transport/curl.php
  3. +22 −0 packager.test.xml
  4. +20 −0 packager.xml
  5. +76 −0 tests/bootstrap.stub.php
View
62 libraries/import.stub.php
@@ -0,0 +1,62 @@
+<?php
+/**
+ * @package Joomla.Platform
+ *
+ * @copyright Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
+ * @license GNU General Public License version 2 or later; see LICENSE
+ */
+
+// Setup the Pharsanity!
+Phar::interceptFileFuncs();
+
+// Set the platform root path as a constant if necessary.
+if (!defined('JPATH_PLATFORM'))
+{
+ define('JPATH_PLATFORM', 'phar://' . __FILE__);
+}
+
+// Detect the native operating system type.
+$os = strtoupper(substr(PHP_OS, 0, 3));
+if (!defined('IS_WIN'))
+{
+ define('IS_WIN', ($os === 'WIN') ? true : false);
+}
+if (!defined('IS_MAC'))
+{
+ define('IS_MAC', ($os === 'MAC') ? true : false);
+}
+if (!defined('IS_UNIX'))
+{
+ define('IS_UNIX', (($os !== 'MAC') && ($os !== 'WIN')) ? true : false);
+}
+
+// Import the platform version library if necessary.
+if (!class_exists('JPlatform'))
+{
+ require_once JPATH_PLATFORM . '/platform.php';
+}
+
+// Import the library loader if necessary.
+if (!class_exists('JLoader'))
+{
+ require_once JPATH_PLATFORM . '/loader.php';
+}
+
+// Make sure that the Joomla Platform has been successfully loaded.
+if (!class_exists('JLoader'))
+{
+ throw new RuntimeException('Joomla Platform not loaded.');
+}
+
+// Setup the autoloaders.
+JLoader::setup();
+
+// Import the base Joomla Platform libraries.
+JLoader::import('joomla.factory');
+
+// Register classes that don't follow one file per class naming conventions.
+JLoader::register('JText', JPATH_PLATFORM . '/joomla/language/text.php');
+JLoader::register('JRoute', JPATH_PLATFORM . '/joomla/application/route.php');
+
+// End of the Phar Stub.
+__HALT_COMPILER();?>
View
2 libraries/joomla/http/transport/curl.php
@@ -68,7 +68,7 @@ public function request($method, JUri $uri, $data = null, array $headers = null,
$options[CURLOPT_NOBODY] = ($method === 'HEAD');
// Initialize the certificate store
- $options[CURLOPT_CAINFO] = __DIR__ . '/cacert.pem';
+ $options[CURLOPT_CAINFO] = $this->options->get('curl.certpath', __DIR__ . '/cacert.pem');
// If data exists let's encode it and make sure our Content-type header is set.
if (isset($data))
View
22 packager.test.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<packager minify="false" alias="joomla-test.phar" destination="build/joomla-test.phar">
+ <code stub="tests/bootstrap.stub.php">
+ <file localPath="lib">libraries/import.php</file>
+ <file localPath="lib">libraries/loader.php</file>
+ <file localPath="lib">libraries/platform.php</file>
+ <folder recursive="true" localPath="lib/joomla">libraries/joomla</folder>
+ <folder recursive="true" localPath="lib/phpmailer">libraries/phpmailer</folder>
+ <folder recursive="true" localPath="lib/phputf8">libraries/phputf8</folder>
+ <folder recursive="true" localPath="lib/simplepie">libraries/simplepie</folder>
+ <folder recursive="true" localPath="core">tests/core</folder>
+ </code>
+
+ <metadata>
+ <element name="version" value="1.0" />
+ <element name="authors">
+ <element name="OpenSourceMatters, Inc.">
+ <element name="email" value="admin@joomla.org" />
+ </element>
+ </element>
+ </metadata>
+</packager>
View
20 packager.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<packager minify="false" alias="joomla.phar" destination="build/joomla.phar">
+ <code stub="libraries/import.stub.php">
+ <file>libraries/loader.php</file>
+ <file>libraries/platform.php</file>
+ <folder recursive="true" localPath="joomla">libraries/joomla</folder>
+ <folder recursive="true" localPath="phpmailer">libraries/phpmailer</folder>
+ <folder recursive="true" localPath="phputf8">libraries/phputf8</folder>
+ <folder recursive="true" localPath="simplepie">libraries/simplepie</folder>
+ </code>
+
+ <metadata>
+ <element name="version" value="1.0" />
+ <element name="authors">
+ <element name="OpenSourceMatters, Inc.">
+ <element name="email" value="admin@joomla.org" />
+ </element>
+ </element>
+ </metadata>
+</packager>
View
76 tests/bootstrap.stub.php
@@ -0,0 +1,76 @@
+<?php
+/**
+ * Prepares a minimalist framework for unit testing.
+ *
+ * Joomla is assumed to include the /unittest/ directory.
+ * eg, /path/to/joomla/unittest/
+ *
+ * @package Joomla.UnitTest
+ *
+ * @copyright Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
+ * @license GNU General Public License version 2 or later; see LICENSE
+ * @link http://www.phpunit.de/manual/current/en/installation.html
+ */
+
+// Setup the Pharsanity!
+Phar::interceptFileFuncs();
+
+// Set the Joomla execution flag.
+define('_JEXEC', 1);
+
+// Fix magic quotes.
+@ini_set('magic_quotes_runtime', 0);
+
+// Maximise error reporting.
+error_reporting(E_ALL & ~E_STRICT);
+ini_set('display_errors', 1);
+
+/*
+ * Ensure that required path constants are defined. These can be overridden within the phpunit.xml file
+ * if you chose to create a custom version of that file.
+ */
+if (!defined('JPATH_TESTS'))
+{
+ define('JPATH_TESTS', __DIR__);
+}
+if (!defined('JPATH_PLATFORM'))
+{
+ define('JPATH_PLATFORM', 'phar://' . __FILE__ . '/lib');
+}
+if (!defined('JPATH_BASE'))
+{
+ define('JPATH_BASE', JPATH_TESTS . '/tmp');
+}
+if (!defined('JPATH_ROOT'))
+{
+ define('JPATH_ROOT', JPATH_BASE);
+}
+if (!defined('JPATH_CACHE'))
+{
+ define('JPATH_CACHE', JPATH_BASE . '/cache');
+}
+if (!defined('JPATH_CONFIGURATION'))
+{
+ define('JPATH_CONFIGURATION', JPATH_BASE);
+}
+if (!defined('JPATH_MANIFESTS'))
+{
+ define('JPATH_MANIFESTS', JPATH_BASE . '/manifests');
+}
+if (!defined('JPATH_PLUGINS'))
+{
+ define('JPATH_PLUGINS', JPATH_BASE . '/plugins');
+}
+if (!defined('JPATH_THEMES'))
+{
+ define('JPATH_THEMES', JPATH_BASE . '/themes');
+}
+
+// Import the platform.
+require_once JPATH_PLATFORM . '/import.php';
+
+// Register the core Joomla test classes.
+JLoader::registerPrefix('Test', 'phar://' . __FILE__ . '/core');
+
+// End of the Phar Stub.
+__HALT_COMPILER();?>

0 comments on commit e441c20

Please sign in to comment.