Permalink
Browse files

Junit runner working just enought

  • Loading branch information...
1 parent 19b0656 commit 51a029560acd80707cf3c8aaeba2121fa41824a6 Amjad Mohamed committed Oct 22, 2011
View
@@ -1,9 +1,10 @@
-<project name="PHPSpec">
+<project name="PHPSpec" default="pearify" basedir="..">
<property name="version" value="1.2.2" />
<property name="stability" value="beta" />
- <property name="pear" value="pear" />
- <property name="source" value="/md/dev/php/phpspec" />
+ <property name="source" value="src" />
+ <property name="build" value="build" />
+ <property name="pear" value="${build}/pear" />
<target name="clean" description="Clean build">
<delete dir="${pear}" />
@@ -12,15 +13,15 @@
<target name="init" description="Create build directory" depends="clean">
<mkdir dir="${pear}" />
<copy toDir="${pear}" >
- <fileset file="${source}/README.markdown" />
- <fileset file="${source}/LICENSE" />
- <fileset file="${source}/scripts/phpspec.php" />
- <fileset file="${source}/scripts/phpspec.bat" />
+ <fileset file="README.markdown" />
+ <fileset file="LICENSE" />
+ <fileset file="scripts/phpspec.php" />
+ <fileset file="scripts/phpspec.bat" />
</copy>
<mkdir dir="${pear}/PHPSpec" />
<copy toDir="${pear}/PHPSpec" >
- <fileset dir="${source}/src/PHPSpec" />
+ <fileset dir="${source}/PHPSpec" />
</copy>
<delete dir="${pear}/PHPSpec/Mocks" />
@@ -29,12 +30,12 @@
<target name="code-sniffer" description="Check standards" depends="init">
<exec executable="phpcs" dir="${pear}/PHPSpec" failonerror="on">
- <arg line="--standard=Zend --ignore=*Functions.php ." />
+ <arg line="--standard=Zend --ignore=*Functions.php -n ." />
</exec>
</target>
<target name="pearify" description="Create the package.xml" depends="code-sniffer">
- <exec executable="pearify">
+ <exec executable="build/pearify">
<arg line="${pear} ${version} ${stability}" />
</exec>
</target>
View
@@ -173,9 +173,11 @@
error_reporting(E_ALL|E_STRICT);
require_once 'PHPSpec/Loader/UniversalClassLoader.php';
+include_once 'Mockery.php';
$paths = explode(':', ini_get('include_path'));
$loader = new \PHPSpec\Loader\UniversalClassLoader();
$loader->registerNamespace('PHPSpec', $paths);
+$loader->registerNamespace('Mockery', $paths);
$loader->register();
$phpspec = new \PHPSpec\PHPSpec($argv);
@@ -96,12 +96,20 @@ public function matches($actual, $epsilon = null)
}
if (is_object($this->_expected) && is_object($this->_actual) &&
(get_class($this->_expected) === get_class($this->_actual))) {
- return $this->_expected === $this->_actual;
+ if ($epsilon === true) {
+ return $this->_expected === $this->_actual;
+ } else {
+ return $this->_expected == $this->_actual;
+ }
}
if (is_array($this->_actual) && is_array($this->_expected)) {
// compare arrays - we'll curently enforce key equality
- return $this->_expected === $this->_actual;
+ if ($epsilon === true) {
+ return $this->_expected === $this->_actual;
+ } else {
+ return $this->_expected == $this->_actual;
+ }
}
if (!is_array($this->_expected) && !is_array($this->_actual) &&
@@ -0,0 +1,67 @@
+<?php
+/**
+ * PHPSpec
+ *
+ * LICENSE
+ *
+ * This file is subject to the GNU Lesser General Public License Version 3
+ * that is bundled with this package in the file LICENSE.
+ * It is also available through the world-wide-web at this URL:
+ * http://www.gnu.org/licenses/lgpl-3.0.txt
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@phpspec.net so we can send you a copy immediately.
+ *
+ * @category PHPSpec
+ * @package PHPSpec
+ * @copyright Copyright (c) 2007-2009 Pádraic Brady, Travis Swicegood
+ * @copyright Copyright (c) 2010-2011 Pádraic Brady, Travis Swicegood,
+ * Marcello Duarte
+ * @license http://www.gnu.org/licenses/lgpl-3.0.txt GNU Lesser General Public Licence Version 3
+ */
+namespace PHPSpec\Runner\Formatter;
+
+/**
+ * @category PHPSpec
+ * @package PHPSpec
+ * @copyright Copyright (c) 2007-2009 Pádraic Brady, Travis Swicegood
+ * @copyright Copyright (c) 2010-2011 Pádraic Brady, Travis Swicegood,
+ * Marcello Duarte
+ * @license http://www.gnu.org/licenses/lgpl-3.0.txt GNU Lesser General Public Licence Version 3
+ */
+use PHPSpec\Runner\Formatter;
+
+abstract class FormatterAbstract implements Formatter
+{
+
+ /**
+ * Listens to events from the reporter, and calls appropriate methods to
+ * update the output
+ *
+ * @param SplSubject $method
+ * @param unknown $reporterEvent
+ */
+ public function update(\SplSubject $method, $reporterEvent = null)
+ {
+ switch ($reporterEvent->event) {
+ case 'start':
+ $this->_startRenderingExampleGroup($reporterEvent);
+ break;
+ case 'finish':
+ $this->_finishRenderingExampleGroup();
+ break;
+ case 'status':
+ $this->_renderExamples($reporterEvent);
+ break;
+ case 'exit':
+ $this->output();
+ exit(0);
+ break;
+ }
+ }
+
+ abstract protected function _startRenderingExampleGroup($reporterEvent);
+ abstract protected function _finishRenderingExampleGroup();
+ abstract protected function _renderExamples($reporterEvent);
+
+}
@@ -101,28 +101,6 @@ protected function getResults()
}
/**
- * Listens to events from the reporter to interact with the HTML report
- * as things happens
- */
- public function update(\SplSubject $method, $reporterEvent = null)
- {
- switch ($reporterEvent->event) {
- case 'start' :
- $this->startRenderingExampleGroup($reporterEvent);
- break;
- case 'finish' :
- $this->finishRenderingExampleGroup();
- break;
- case 'status' :
- $this->rendersExamplesSpecdox($reporterEvent);
- break;
- case 'exit':
- $this->output();
- exit;
- break;
- }
- }
- /**
* Gets the template directory
*
* @return string
@@ -157,7 +135,7 @@ public function put($output)
*
* @param ReporterEvent $reporterEvent
*/
- private function startRenderingExampleGroup($reporterEvent)
+ protected function _startRenderingExampleGroup($reporterEvent)
{
static $groupIndex = 1;
$template = new \Text_Template(
@@ -175,7 +153,7 @@ private function startRenderingExampleGroup($reporterEvent)
/**
* Finishes rendering example group
*/
- private function finishRenderingExampleGroup()
+ protected function _finishRenderingExampleGroup()
{
$template = new \Text_Template(
$this->templateDir() . '/GroupEnd.html.dist'
@@ -190,7 +168,7 @@ private function finishRenderingExampleGroup()
*
* @param ReporterEvent $reporterEvent
*/
- private function rendersExamplesSpecdox($reporterEvent)
+ protected function _renderExamples($reporterEvent)
{
$this->_examples .= $this->specdox(
$reporterEvent->status, $reporterEvent->example,
Oops, something went wrong.

0 comments on commit 51a0295

Please sign in to comment.