Skip to content

Commit

Permalink
Fix code standard violations
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcelloDuarte committed Aug 1, 2012
1 parent c49c8da commit 8a05eb5
Show file tree
Hide file tree
Showing 22 changed files with 1,022 additions and 176 deletions.
5 changes: 3 additions & 2 deletions src/PHPSpec/Context/Zend.php
Expand Up @@ -21,8 +21,9 @@
*/
namespace PHPSpec\Context;

use \PHPSpec\Context,
\PHPSpec\Context\Zend\ZendTest;
use PHPSpec\Context;
use PHPSpec\Context\Zend\ZendTest;

/**
* @category PHPSpec
* @package PHPSpec_Zend
Expand Down
33 changes: 29 additions & 4 deletions src/PHPSpec/Context/Zend/Controller.php
Expand Up @@ -277,24 +277,38 @@ public function update($event)
{
switch ($event['method']) {
case 'render':
$this->_rendered[] = str_replace('.phtml', '', $event['action']);
$this->_rendered[] = str_replace(
'.phtml', '', $event['action']
);
break;
case 'renderScript':
$this->_rendered[] = str_replace('.phtml', '', $event['script']);
$this->_rendered[] = str_replace(
'.phtml', '', $event['script']
);
break;
case 'renderView':
$this->_rendered[] = str_replace('.phtml', '', $event['name']);
$this->_rendered[] = str_replace(
'.phtml', '', $event['name']
);
break;
case 'assign':
$this->_assigned[$event['viewVariable']] = $event['value'];
break;
case 'redirect':
$this->response = $this->spec($this->_getZendTest()->getFrontController()->getResponse());
$this->response = $this->spec(
$this->_getZendTest()->getFrontController()->getResponse()
);
$this->response->getActualValue()->setRedirect($event['url']);
break;
}
}

/**
* Used so controller can be checked e.g. $this->should->renderView('hi')
*
* @param string $property
* @return PHPSpec\Specification\Interceptor
*/
public function __get($property)
{
if ($property === 'should') {
Expand All @@ -307,11 +321,22 @@ public function __get($property)
trigger_error("Undefined property: $class::\$$property");
}

/**
* Checks if a view has been rendered
*
* @param string $view
* @return boolean
*/
public function hasRenderedView($view)
{
return in_array($view, $this->_rendered);
}

/**
* Gets the rendered views
*
* @return array
*/
public function getRenderedViews()
{
return $this->_rendered;
Expand Down
6 changes: 6 additions & 0 deletions src/PHPSpec/Context/Zend/Dispatcher.php
Expand Up @@ -53,6 +53,12 @@ class Dispatcher extends StandardDispatcher

/**
* @inheritdoc
*
* This code is based on the ZF Standard dispatcher
* @licence http://framework.zend.com/license/new-bsd
*
* Copyright (c) 2005-2010, Zend Technologies USA, Inc.
* All rights reserved.
*/
public function dispatch(Request $request, Response $response)
{
Expand Down
3 changes: 1 addition & 2 deletions src/PHPSpec/Context/Zend/Filter/Pluralize.php
Expand Up @@ -477,8 +477,7 @@
* configurations.
*
* It was ported to PHP for the Akelos Framework, a
* multilingual Ruby on Rails like framework for PHP that will
* be launched soon.
* multilingual Ruby on Rails like framework for PHP
*
* I have adapted a bit as is was not passing my tests :) (-- Marcello Duarte)
*
Expand Down
3 changes: 1 addition & 2 deletions src/PHPSpec/Context/Zend/Filter/Singularize.php
Expand Up @@ -477,8 +477,7 @@
* configurations.
*
* It was ported to PHP for the Akelos Framework, a
* multilingual Ruby on Rails like framework for PHP that will
* be launched soon.
* multilingual Ruby on Rails like framework for PHP
*
* I have adapted a bit as is was not passing my tests :) (-- Marcello Duarte)
*
Expand Down
15 changes: 15 additions & 0 deletions src/PHPSpec/Context/Zend/Filter/UCFirst.php
Expand Up @@ -25,6 +25,14 @@
*/
require_once 'Zend/Filter/Interface.php';

/**
* @category PHPSpec
* @package PHPSpec_Zend
* @copyright Copyright (c) 2007-2009 Pádraic Brady, Travis Swicegood
* @copyright Copyright (c) 2010-2012 Pádraic Brady, Travis Swicegood,
* Marcello Duarte
* @license http://www.gnu.org/licenses/lgpl-3.0.txt GNU Lesser General Public Licence Version 3
*/
class PHPSpec_Context_Zend_Filter_UCFirst implements Zend_Filter_Interface
{

Expand All @@ -44,6 +52,13 @@ public function filter($value)
return $value;
}

/**
* Provides a static interface for functional use
*
* @param string $value
*
* @return string String filtered
*/
public static function apply($value)
{
$filter = new static;
Expand Down
9 changes: 5 additions & 4 deletions src/PHPSpec/Context/Zend/Matcher/HaveSelector.php
Expand Up @@ -24,10 +24,11 @@
/**
* @see \PHPSpec\Matcher
*/
use \PHPSpec\Matcher,
\PHPSpec\Util\Validate,
\PHPSpec\Specification\Interceptor\InterceptorFactory,
\Zend_Dom_Query as DomQuery;
use PHPSpec\Matcher;
use PHPSpec\Util\Validate;
use PHPSpec\Specification\Interceptor\InterceptorFactory;

use Zend_Dom_Query as DomQuery;

/**
* @category PHPSpec
Expand Down
83 changes: 79 additions & 4 deletions src/PHPSpec/Context/Zend/Spy/Controller.php.dist
@@ -1,16 +1,57 @@

/**
* 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-2012 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\Context\Zend\Spy\View as SpyView;
use PHPSpec\Context\Zend\Spy\Observer;
use PHPSpec\Context\Zend\Spy\Subject;

use \Zend_Controller_Action_HelperBroker as HelperBroker;
use \Zend_Controller_Action_Helper_ViewRenderer as ViewRenderer;
use Zend_Controller_Action_HelperBroker as HelperBroker;
use Zend_Controller_Action_Helper_ViewRenderer as ViewRenderer;
use Zend_Controller_Request_Abstract as Request;
use Zend_Controller_Response_Abstract as Response;

/**
* @category PHPSpec
* @package PHPSpec_Zend
* @copyright Copyright (c) 2007-2009 Pádraic Brady, Travis Swicegood
* @copyright Copyright (c) 2010-2012 Pádraic Brady, Travis Swicegood,
* Marcello Duarte
* @license http://www.gnu.org/licenses/lgpl-3.0.txt GNU Lesser General Public Licence Version 3
*/
class {spyController} extends {userController} implements Subject
{
/**
* Observers attached to the controller
*
* @var string
*/
protected $observers = array();

public function __construct(Zend_Controller_Request_Abstract $request, Zend_Controller_Response_Abstract $response, array $invokeArgs = array())
/**
* Creates the controller
*
* @param Request $request
* @param Response $response
* @param array $invokeArgs
*/
public function __construct(Request $request, Response $response, array $invokeArgs = array())
{
parent::__construct($request, $response, $invokeArgs);
$helper = $this->_helper;
Expand All @@ -20,18 +61,35 @@ class {spyController} extends {userController} implements Subject
$helper::addHelper($viewRenderer);
}

/**
* Initiates the view
*
* @return PHPSpec\Context\Zend\Spy\View
*/
public function initView()
{
$this->view = new SpyView;
return $this->view;
}

/**
* Attaches an observer
*
* @param Observer $observer
*/
public function attach(Observer $observer)
{
$this->observers[] = $observer;
$this->view->attach($observer);
}

/**
* Intercepts rendering the view and notify the observers
*
* @param string $action
* @param string $name
* @param boolean $noController
*/
public function render($action = null, $name = null, $noController = false)
{
$spyData = array(
Expand All @@ -43,6 +101,12 @@ class {spyController} extends {userController} implements Subject
$this->notify($spyData);
}

/**
* Intercepts rendering a view script and notify the observers
*
* @param string $script
* @param string $name
*/
public function renderScript($script, $name = null)
{
$spyData = array(
Expand All @@ -53,6 +117,12 @@ class {spyController} extends {userController} implements Subject
$this->notify($spyData);
}

/**
* Intercepts redirects
*
* @param string $url
* @param array $options
*/
public function _redirect($url, array $options = array())
{
$spyData = array(
Expand All @@ -63,6 +133,11 @@ class {spyController} extends {userController} implements Subject
$this->notify($spyData);
}

/**
* Notifies observers
*
* @param array $spyData
*/
public function notify($spyData)
{
foreach($this->observers as $observer) {
Expand Down
34 changes: 33 additions & 1 deletion src/PHPSpec/Context/Zend/Spy/Observer.php
@@ -1,8 +1,40 @@
<?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-2012 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\Context\Zend\Spy;

/**
* @category PHPSpec
* @package PHPSpec_Zend
* @copyright Copyright (c) 2007-2009 Pádraic Brady, Travis Swicegood
* @copyright Copyright (c) 2010-2012 Pádraic Brady, Travis Swicegood,
* Marcello Duarte
* @license http://www.gnu.org/licenses/lgpl-3.0.txt GNU Lesser General Public Licence Version 3
*/
interface Observer
{
/**
* Updates the observer
*
* @param array $event
*/
public function update($event);
}
40 changes: 39 additions & 1 deletion src/PHPSpec/Context/Zend/Spy/Subject.php
@@ -1,9 +1,47 @@
<?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-2012 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\Context\Zend\Spy;

/**
* @category PHPSpec
* @package PHPSpec_Zend
* @copyright Copyright (c) 2007-2009 Pádraic Brady, Travis Swicegood
* @copyright Copyright (c) 2010-2012 Pádraic Brady, Travis Swicegood,
* Marcello Duarte
* @license http://www.gnu.org/licenses/lgpl-3.0.txt GNU Lesser General Public Licence Version 3
*/
interface Subject
{
/**
* Attaches an observer
*
* @param Observer $observer
*/
public function attach(Observer $observer);

/**
* Notifies the observers
*
* @param array $event
*/
public function notify($event);
}

0 comments on commit 8a05eb5

Please sign in to comment.