Author: Jonathan.Wage
Date: 2009-05-12 19:29:33 +0200 (Tue, 12 May 2009)
New Revision: 18181
Added:
plugins/sfSympalPlugin/trunk/lib/email/sfSympalMail.class.php
plugins/sfSympalPlugin/trunk/tests/fixtures/project/apps/sympal/modules/test/
plugins/sfSympalPlugin/trunk/tests/fixtures/project/apps/sympal/modules/test/actions/
plugins/sfSympalPlugin/trunk/tests/fixtures/project/apps/sympal/modules/test/actions/actions.class.php
plugins/sfSympalPlugin/trunk/tests/fixtures/project/apps/sympal/modules/test/templates/
plugins/sfSympalPlugin/trunk/tests/fixtures/project/apps/sympal/modules/test/templates/_email.php
plugins/sfSympalPlugin/trunk/tests/fixtures/project/apps/sympal/modules/test/templates/_test.php
plugins/sfSympalPlugin/trunk/tests/fixtures/project/apps/sympal/modules/test/templates/ask_confirmationSuccess.php
plugins/sfSympalPlugin/trunk/tests/fixtures/project/apps/sympal/modules/test/templates/change_layoutSuccess.php
plugins/sfSympalPlugin/trunk/tests/fixtures/project/apps/sympal/templates/test.php
plugins/sfSympalPlugin/trunk/tests/fixtures/project/web/css/test.css
plugins/sfSympalPlugin/trunk/tests/functional/ActionsTest.php
plugins/sfSympalPlugin/trunk/tests/unit/ConfigTest.php
plugins/sfSympalPlugin/trunk/tests/unit/ConfigurationTest.php
plugins/sfSympalPlugin/trunk/tests/unit/DiffTest.php
plugins/sfSympalPlugin/trunk/tests/unit/EmailTest.php
plugins/sfSympalPlugin/trunk/tests/unit/EventsTest.php
plugins/sfSympalPlugin/trunk/tests/unit/HelperTest.php
plugins/sfSympalPlugin/trunk/tests/unit/MarkdownTest.php
plugins/sfSympalPlugin/trunk/tests/unit/ToolkitsTest.php
plugins/sfSympalPlugin/trunk/tests/unit/UserSessionTest.php
Removed:
plugins/sfSympalPlugin/trunk/lib/email/sfSympalEmail.class.php
plugins/sfSympalPlugin/trunk/tests/unit/BreadcrumbsTest.php
Modified:
plugins/sfSympalPlugin/trunk/config/app.yml
plugins/sfSympalPlugin/trunk/lib/actions/sfSympalActions.class.php
plugins/sfSympalPlugin/trunk/lib/helper/SympalHelper.php
plugins/sfSympalPlugin/trunk/lib/toolkits/sfSympalToolkit.class.php
plugins/sfSympalPlugin/trunk/lib/user/sfSympalUser.class.php
plugins/sfSympalPlugin/trunk/tests/fixtures/project/apps/sympal/config/routing.yml
plugins/sfSympalPlugin/trunk/tests/fixtures/project/apps/sympal/config/settings.yml
plugins/sfSympalPlugin/trunk/tests/unit/ContentTest.php
plugins/sfSympalPlugin/trunk/tests/unit/MenuItemTest.php
plugins/sfSympalPlugin/trunk/tests/unit/MenuTest.php
plugins/sfSympalPlugin/trunk/tests/unit/PluginManager1Test.php
plugins/sfSympalPlugin/trunk/tests/unit/PluginManager2Test.php
plugins/sfSympalPlugin/trunk/tests/unit/VersionTest.php
Log:
[1.0] sfSympalPlugin: Adding more general test coverage
Modified: plugins/sfSympalPlugin/trunk/config/app.yml
===================================================================
--- plugins/sfSympalPlugin/trunk/config/app.yml 2009-05-12 15:25:32 UTC (rev
18180)
+++ plugins/sfSympalPlugin/trunk/config/app.yml 2009-05-12 17:29:33 UTC (rev
18181)
@@ -10,7 +10,7 @@
i18n: true
versioning: true
versioned_models:
- Content: [created_by, is_published, date_published]
+ Content: [created_by, is_published, date_published, slug]
ContentTranslation: [page_title, meta_keywords, meta_description]
ContentSlotTranslation: [value]
PageTranslation: [title]
Modified: plugins/sfSympalPlugin/trunk/lib/actions/sfSympalActions.class.php
===================================================================
--- plugins/sfSympalPlugin/trunk/lib/actions/sfSympalActions.class.php
2009-05-12 15:25:32 UTC (rev 18180)
+++ plugins/sfSympalPlugin/trunk/lib/actions/sfSympalActions.class.php
2009-05-12 17:29:33 UTC (rev 18181)
@@ -88,13 +88,13 @@
public function getEmailTemplateFor($module, $action, $variables = array())
{
- $variables =
sfProjectConfiguration::getActive()->getEventDispatcher()->notify(new
sfEvent($this, 'sympal.email.filter_variables'), $variables)->getReturnValue();
+ $variables =
sfProjectConfiguration::getActive()->getEventDispatcher()->filter(new
sfEvent($this, 'sympal.email.filter_variables'), $variables)->getReturnValue();
sfContext::getInstance()->getConfiguration()->loadHelpers(array('Partial'));
$email = sfSympalToolkit::getSymfonyResource($module, $action, $variables);
- $email =
sfProjectConfiguration::getActive()->getEventDispatcher()->notify(new
sfEvent($this, 'sympal.email.filter_template', array('module' => $module,
'action' => $action, 'variables' => $variables)), $email)->getReturnValue();
+ $email =
sfProjectConfiguration::getActive()->getEventDispatcher()->filter(new
sfEvent($this, 'sympal.email.filter_template', array('module' => $module,
'action' => $action, 'variables' => $variables)), $email)->getReturnValue();
return $email;
}
@@ -128,14 +128,15 @@
return $this->mail;
}
- public function forwardToRoute($full)
+ public function forwardToRoute($route, $params = array())
{
- if (strstr($full, '?'))
+ $full = $route;
+ if (strstr($route, '?'))
{
- $pos = strpos($full, '?');
- $route = substr($full, 1, $pos - 1);
+ $pos = strpos($route, '?');
+ $route = substr($route, 1, $pos - 1);
} else {
- $route = substr($full, 1, strlen($full));
+ $route = substr($route, 1, strlen($route));
}
$r = $this->getContext()->getRouting();
@@ -147,28 +148,25 @@
if (isset($pos))
{
- $params = substr($full, $pos + 1, strlen($full));
- $e = explode('&', $params);
+ $p = substr($full, $pos + 1, strlen($full));
+ $e = explode('&', $p);
- foreach ($e as $param)
+ foreach ($e as $k => $v)
{
- $e2 = explode('=', $param);
+ $e2 = explode('=', $v);
if ((isset($e2[0]) && $e2[0]) && (isset($e2[1]) && $e2[1]))
{
- $this->getRequest()->setParameter($e2[0], $e2[1]);
+ $params[$e2[0]] = $e2[1];
}
}
}
$routeInfo = $routes[$route];
- $params = $routeInfo[3];
+ $params = array_merge($routeInfo->getDefaults(), $params);
foreach ($params as $key => $value)
{
- if ($value)
- {
- $this->getRequest()->setParameter($key, $value);
- }
+ $this->getRequest()->setParameter($key, $value);
}
$this->forward($params['module'], $params['action']);
Deleted: plugins/sfSympalPlugin/trunk/lib/email/sfSympalEmail.class.php
===================================================================
--- plugins/sfSympalPlugin/trunk/lib/email/sfSympalEmail.class.php
2009-05-12 15:25:32 UTC (rev 18180)
+++ plugins/sfSympalPlugin/trunk/lib/email/sfSympalEmail.class.php
2009-05-12 17:29:33 UTC (rev 18181)
@@ -1,75 +0,0 @@
-<?php
-
-class sfSympalMail
-{
- protected
- $_mailer,
- $_message,
- $_emailAddress,
- $_fromAddress;
-
- public function __construct()
- {
- $this->_mailer = new Swift(new Swift_Connection_NativeMail());
- }
-
- public function setEmailAddress($emailAddress)
- {
- $this->_emailAddress = $emailAddress;
- }
-
- public function setFromAddress($fromAddress)
- {
- $this->_fromAddress = $fromAddress;
- }
-
- public function setMessage($subject, $body = null, $type = 'text/html')
- {
- if (!$subject instanceof Swift_Message)
- {
- $this->_message = new Swift_Message($subject, $body, $type);
- } else {
- $this->_message = $subject;
- }
-
- return $this->_message;
- }
-
- public function getMessage()
- {
- return $this->_message;
- }
-
- public function send($emailAddress = null, $fromAddress = null)
- {
- sfProjectConfiguration::getActive()->getEventDispatcher()->notify(new
sfEvent($this, 'sympal.email.pre_send', array('mailer' => $this->_mailer,
'message' => $this->_message, 'email_address' => $emailAddress)));
-
- $emailAddress = $emailAddress ? $emailAddress:$this->_emailAddress;
- $fromAddress = $fromAddress ? $fromAddress:$this->_fromAddress;
-
- if (!$fromAddress)
- {
- $fromAddress = sfSympalConfig::get('default_from_email_address', null,
'[email protected]');
- }
-
- $this->_mailer->send($this->_message, $emailAddress, $fromAddress);
- $this->_mailer->disconnect();
-
- sfProjectConfiguration::getActive()->getEventDispatcher()->notify(new
sfEvent($this, 'sympal.email.post_send', array('mailer' => $this->_mailer,
'message' => $this->_message, 'email_address' => $emailAddress)));
- }
-
- public function __get($name)
- {
- return $this->_mailer->$name;
- }
-
- public function __set($name, $value)
- {
- $this->_mailer->$name = $value;
- }
-
- public function __call($method, $arguments)
- {
- return call_user_func_array(array($this->_mailer, $method), $arguments);
- }
-}
\ No newline at end of file
Added: plugins/sfSympalPlugin/trunk/lib/email/sfSympalMail.class.php
===================================================================
--- plugins/sfSympalPlugin/trunk/lib/email/sfSympalMail.class.php
(rev 0)
+++ plugins/sfSympalPlugin/trunk/lib/email/sfSympalMail.class.php
2009-05-12 17:29:33 UTC (rev 18181)
@@ -0,0 +1,75 @@
+<?php
+
+class sfSympalMail
+{
+ protected
+ $_mailer,
+ $_message,
+ $_emailAddress,
+ $_fromAddress;
+
+ public function __construct()
+ {
+ $this->_mailer = new Swift(new Swift_Connection_NativeMail());
+ }
+
+ public function setEmailAddress($emailAddress)
+ {
+ $this->_emailAddress = $emailAddress;
+ }
+
+ public function setFromAddress($fromAddress)
+ {
+ $this->_fromAddress = $fromAddress;
+ }
+
+ public function setMessage($subject, $body = null, $type = 'text/html')
+ {
+ if (!$subject instanceof Swift_Message)
+ {
+ $this->_message = new Swift_Message($subject, $body, $type);
+ } else {
+ $this->_message = $subject;
+ }
+
+ return $this->_message;
+ }
+
+ public function getMessage()
+ {
+ return $this->_message;
+ }
+
+ public function send($emailAddress = null, $fromAddress = null)
+ {
+ sfProjectConfiguration::getActive()->getEventDispatcher()->notify(new
sfEvent($this, 'sympal.email.pre_send', array('mailer' => $this->_mailer,
'message' => $this->_message, 'email_address' => $emailAddress)));
+
+ $emailAddress = $emailAddress ? $emailAddress:$this->_emailAddress;
+ $fromAddress = $fromAddress ? $fromAddress:$this->_fromAddress;
+
+ if (!$fromAddress)
+ {
+ $fromAddress = sfSympalConfig::get('default_from_email_address', null,
'[email protected]');
+ }
+
+ $this->_mailer->send($this->_message, $emailAddress, $fromAddress);
+ $this->_mailer->disconnect();
+
+ sfProjectConfiguration::getActive()->getEventDispatcher()->notify(new
sfEvent($this, 'sympal.email.post_send', array('mailer' => $this->_mailer,
'message' => $this->_message, 'email_address' => $emailAddress)));
+ }
+
+ public function __get($name)
+ {
+ return $this->_mailer->$name;
+ }
+
+ public function __set($name, $value)
+ {
+ $this->_mailer->$name = $value;
+ }
+
+ public function __call($method, $arguments)
+ {
+ return call_user_func_array(array($this->_mailer, $method), $arguments);
+ }
+}
\ No newline at end of file
Modified: plugins/sfSympalPlugin/trunk/lib/helper/SympalHelper.php
===================================================================
--- plugins/sfSympalPlugin/trunk/lib/helper/SympalHelper.php 2009-05-12
15:25:32 UTC (rev 18180)
+++ plugins/sfSympalPlugin/trunk/lib/helper/SympalHelper.php 2009-05-12
17:29:33 UTC (rev 18181)
@@ -19,19 +19,21 @@
if (sfConfig::get('sf_debug'))
{
- $fullPath = sfConfig::get('sf_web_dir').$path.($type == 'css' ?
'.css':'.js');
- if (!file_exists($fullPath))
- {
- throw new sfException('YUI path does not exist: "'.$fullPath.'"');
- }
- } else {
$minPath = $path.'-min';
- if (file_exists(sfConfig::get('sf_web_dir').$minPath))
+ $fullMinPath = sfConfig::get('sf_web_dir').$minPath.($type == 'css' ?
'.css':'.js');
+
+ if (file_exists($fullMinPath))
{
$path = $minPath;
}
}
+ $fullPath = sfConfig::get('sf_web_dir').$path.($type == 'css' ?
'.css':'.js');
+ if (!file_exists($fullPath))
+ {
+ throw new sfException('YUI path does not exist: "'.$fullPath.'"');
+ }
+
return $path;
}
Modified: plugins/sfSympalPlugin/trunk/lib/toolkits/sfSympalToolkit.class.php
===================================================================
--- plugins/sfSympalPlugin/trunk/lib/toolkits/sfSympalToolkit.class.php
2009-05-12 15:25:32 UTC (rev 18180)
+++ plugins/sfSympalPlugin/trunk/lib/toolkits/sfSympalToolkit.class.php
2009-05-12 17:29:33 UTC (rev 18181)
@@ -43,8 +43,15 @@
return self::getCurrentSite()->id;
}
- public static function getSymfonyResource($module, $action, $variables =
array())
+ public static function getSymfonyResource($module, $action = null,
$variables = array())
{
+ if (strpos($module, '/'))
+ {
+ $variables = (array) $action;
+ $e = explode('/', $module);
+ list($module, $action) = $e;
+ }
+
sfContext::getInstance()->getConfiguration()->loadHelpers('Partial');
try {
@@ -85,7 +92,7 @@
$routingPath =
sfConfig::get('sf_root_dir').'/apps/'.$app.'/config/routing.yml';
$routes = sfYaml::load(file_get_contents($routingPath));
- if (isset($routes['homepage']) || isset($routes['default']) ||
isset($routes['default_index']))
+ if (isset($routes['homepage']) || isset($routes['default_index']))
{
throw new sfException('Your application routing file must not have a
homepage, default, or default_index route defined.');
}
@@ -285,13 +292,13 @@
public static function getAllLanguageCodes()
{
$flags = sfFinder::type('file')
-
->in(sfContext::getInstance()->getConfiguration()->getPluginConfiguration($pluginName)->getRootDir().'/web/images/flags');
+
->in(sfContext::getInstance()->getConfiguration()->getPluginConfiguration('sfSympalPlugin')->getRootDir().'/web/images/flags');
$codes = array();
foreach ($flags as $flag)
{
$info = pathinfo($flag);
- $codes[] = $info['basename'];
+ $codes[] = $info['filename'];
}
return $codes;
}
Modified: plugins/sfSympalPlugin/trunk/lib/user/sfSympalUser.class.php
===================================================================
--- plugins/sfSympalPlugin/trunk/lib/user/sfSympalUser.class.php
2009-05-12 15:25:32 UTC (rev 18180)
+++ plugins/sfSympalPlugin/trunk/lib/user/sfSympalUser.class.php
2009-05-12 17:29:33 UTC (rev 18181)
@@ -7,7 +7,7 @@
$_flash = false,
$_openContentLock = null;
- public function checkContentSecurity($content)
+ public function hasAccessToContent($content)
{
$access = true;
$allPermissions = $content->getAllPermissions();
@@ -21,7 +21,13 @@
{
$access = false;
}
+
+ return $access;
+ }
+ public function checkContentSecurity($content)
+ {
+ $access = $this->hasAccessToContent($content);
if (!$access && !$this->_forwarded)
{
$this->_forwarded = true;
Modified:
plugins/sfSympalPlugin/trunk/tests/fixtures/project/apps/sympal/config/routing.yml
===================================================================
---
plugins/sfSympalPlugin/trunk/tests/fixtures/project/apps/sympal/config/routing.yml
2009-05-12 15:25:32 UTC (rev 18180)
+++
plugins/sfSympalPlugin/trunk/tests/fixtures/project/apps/sympal/config/routing.yml
2009-05-12 17:29:33 UTC (rev 18181)
@@ -0,0 +1,6 @@
+default:
+ url: /:module/:action/*
+
+forward_to_route:
+ url: /forward/to/route/:param1/:param2
+ param: { module: test, action: route_to_forward_to }
\ No newline at end of file
Modified:
plugins/sfSympalPlugin/trunk/tests/fixtures/project/apps/sympal/config/settings.yml
===================================================================
---
plugins/sfSympalPlugin/trunk/tests/fixtures/project/apps/sympal/config/settings.yml
2009-05-12 15:25:32 UTC (rev 18180)
+++
plugins/sfSympalPlugin/trunk/tests/fixtures/project/apps/sympal/config/settings.yml
2009-05-12 17:29:33 UTC (rev 18181)
@@ -23,7 +23,7 @@
all:
.settings:
# Form security secret (CSRF protection)
- csrf_secret: sympals3cr3t # Unique secret to enable CSRF
protection or false to disable
+ csrf_secret: false # Unique secret to enable CSRF
protection or false to disable
# Output escaping settings
escaping_strategy: true # Determines how variables are
made available to templates. Accepted values: on, off.
Added:
plugins/sfSympalPlugin/trunk/tests/fixtures/project/apps/sympal/modules/test/actions/actions.class.php
===================================================================
---
plugins/sfSympalPlugin/trunk/tests/fixtures/project/apps/sympal/modules/test/actions/actions.class.php
(rev 0)
+++
plugins/sfSympalPlugin/trunk/tests/fixtures/project/apps/sympal/modules/test/actions/actions.class.php
2009-05-12 17:29:33 UTC (rev 18181)
@@ -0,0 +1,68 @@
+<?php
+
+/**
+ * test actions.
+ *
+ * @package sympal
+ * @subpackage test
+ * @author Your name here
+ * @version SVN: $Id: actions.class.php 12479 2008-10-31 10:54:40Z fabien $
+ */
+class testActions extends sfActions
+{
+ public function executeAsk_confirmation(sfWebRequest $request)
+ {
+ $this->askConfirmation('Are you sure?', 'Are you sure you wish to execute
this?');
+ }
+
+ public function executeNew_email(sfWebRequest $request)
+ {
+ $dispatcher = sfProjectConfiguration::getActive()->getEventDispatcher();
+ $dispatcher->connect('sympal.email.filter_variables', array($this,
'filterEmailVariables'));
+
+ $email = $this->newEmail('test/email', array('variable' => 'Test
variable'));
+ $request->setAttribute('email', $email);
+
+ return sfView::NONE;
+ }
+
+ public function filterEmailVariables(sfEvent $event, $variables)
+ {
+ $variables['variable2'] = 'Test variable 2';
+
+ return $variables;
+ }
+
+ public function executeForward_to_route()
+ {
+ $this->forwardToRoute('@forward_to_route?param1=value1¶m2=value2');
+ }
+
+ public function executeForward_to_route2()
+ {
+ $this->forwardToRoute('@forward_to_route', array(
+ 'param1' => 'value1',
+ 'param2' => 'value2'
+ ));
+ }
+
+ public function executeRoute_to_forward_to()
+ {
+ return sfView::NONE;
+ }
+
+ public function executeStart_go_back()
+ {
+ return sfView::NONE;
+ }
+
+ public function executeGo_back()
+ {
+ $this->goBack();
+ }
+
+ public function executeChange_layout()
+ {
+ $this->changeLayout('test');
+ }
+}
\ No newline at end of file
Added:
plugins/sfSympalPlugin/trunk/tests/fixtures/project/apps/sympal/modules/test/templates/_email.php
===================================================================
---
plugins/sfSympalPlugin/trunk/tests/fixtures/project/apps/sympal/modules/test/templates/_email.php
(rev 0)
+++
plugins/sfSympalPlugin/trunk/tests/fixtures/project/apps/sympal/modules/test/templates/_email.php
2009-05-12 17:29:33 UTC (rev 18181)
@@ -0,0 +1,2 @@
+Subject
+Body <?php echo $variable ?> <?php echo $variable2 ?>
\ No newline at end of file
Added:
plugins/sfSympalPlugin/trunk/tests/fixtures/project/apps/sympal/modules/test/templates/_test.php
===================================================================
---
plugins/sfSympalPlugin/trunk/tests/fixtures/project/apps/sympal/modules/test/templates/_test.php
(rev 0)
+++
plugins/sfSympalPlugin/trunk/tests/fixtures/project/apps/sympal/modules/test/templates/_test.php
2009-05-12 17:29:33 UTC (rev 18181)
@@ -0,0 +1 @@
+Test
\ No newline at end of file
Added:
plugins/sfSympalPlugin/trunk/tests/fixtures/project/apps/sympal/modules/test/templates/ask_confirmationSuccess.php
===================================================================
---
plugins/sfSympalPlugin/trunk/tests/fixtures/project/apps/sympal/modules/test/templates/ask_confirmationSuccess.php
(rev 0)
+++
plugins/sfSympalPlugin/trunk/tests/fixtures/project/apps/sympal/modules/test/templates/ask_confirmationSuccess.php
2009-05-12 17:29:33 UTC (rev 18181)
@@ -0,0 +1 @@
+Ok!
\ No newline at end of file
Added:
plugins/sfSympalPlugin/trunk/tests/fixtures/project/apps/sympal/templates/test.php
===================================================================
---
plugins/sfSympalPlugin/trunk/tests/fixtures/project/apps/sympal/templates/test.php
(rev 0)
+++
plugins/sfSympalPlugin/trunk/tests/fixtures/project/apps/sympal/templates/test.php
2009-05-12 17:29:33 UTC (rev 18181)
@@ -0,0 +1,13 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+ <head>
+ <?php include_http_metas() ?>
+ <?php include_metas() ?>
+ <?php include_title() ?>
+ <link rel="shortcut icon" href="/favicon.ico" />
+ </head>
+ <body>
+ <h1>Test Layout</h1>
+ <?php echo $sf_content ?>
+ </body>
+</html>
\ No newline at end of file
Added: plugins/sfSympalPlugin/trunk/tests/functional/ActionsTest.php
===================================================================
--- plugins/sfSympalPlugin/trunk/tests/functional/ActionsTest.php
(rev 0)
+++ plugins/sfSympalPlugin/trunk/tests/functional/ActionsTest.php
2009-05-12 17:29:33 UTC (rev 18181)
@@ -0,0 +1,88 @@
+<?php
+require_once(dirname(__FILE__).'/../bootstrap/functional.php');
+
+$browser = new sfTestFunctional(new sfBrowser());
+
+$browser->post('/security/signin', array(
+ 'signin' => array(
+ 'username' => 'admin',
+ 'password' => 'admin'
+ )
+));
+
+$browser->
+ get('/test/ask_confirmation')->
+ click('Yes')->
+ with('request')->begin()->
+ isParameter('sympal_ask_confirmation', 1)->
+ isParameter('yes', 'Yes')->
+ end()->
+ with('response')->begin()->
+ contains('Ok!')->
+ end()->
+ get('/admin/dashboard')->
+ get('/test/ask_confirmation')->
+ click('No')->
+ with('response')->begin()->
+ isRedirected()->
+ followRedirect()->
+ end()->
+ with('request')->begin()->
+ isParameter('module', 'sympal_dashboard')->
+ isParameter('action', 'index')->
+ end()
+;
+
+$browser->get('test/new_email');
+
+$actions =
$browser->getContext()->getController()->getActionStack()->getLastEntry()->getActionInstance();
+$email = $browser->getRequest()->getAttribute('email');
+$message = $email->getMessage();
+
+$t = $browser->test();
+$t->is($message->getSubject(), 'Subject');
+$t->is($message->getBody(), "Body Test variable Test variable 2");
+
+$browser->
+ get('/test/forward_to_route')->
+ with('request')->begin()->
+ isParameter('module', 'test')->
+ isParameter('action', 'route_to_forward_to')->
+ isParameter('param1', 'value1')->
+ isParameter('param2', 'value2')->
+ end()
+;
+
+$browser->
+ get('/test/forward_to_route2')->
+ with('request')->begin()->
+ isParameter('module', 'test')->
+ isParameter('action', 'route_to_forward_to')->
+ isParameter('param1', 'value1')->
+ isParameter('param2', 'value2')->
+ end()
+;
+
+$browser->
+ get('/test/start_go_back')->
+ get('/test/go_back')->
+ isRedirected()->
+ followRedirect()->
+ with('request')->begin()->
+ isParameter('module', 'test')->
+ isParameter('action', 'start_go_back')->
+ end()
+;
+
+$browser->get('/test/change_layout');
+
+$response = $browser->getResponse();
+
+$stylesheets = $response->getStylesheets();
+$t->is(isset($stylesheets['test']), true);
+
+$browser->
+ with('response')->begin()->
+ contains('Test Layout')->
+ end()
+;
\ No newline at end of file
Deleted: plugins/sfSympalPlugin/trunk/tests/unit/BreadcrumbsTest.php
===================================================================
--- plugins/sfSympalPlugin/trunk/tests/unit/BreadcrumbsTest.php 2009-05-12
15:25:32 UTC (rev 18180)
+++ plugins/sfSympalPlugin/trunk/tests/unit/BreadcrumbsTest.php 2009-05-12
17:29:33 UTC (rev 18181)
@@ -1,8 +0,0 @@
-<?php
-$app = 'sympal';
-require_once(dirname(__FILE__).'/../bootstrap/unit.php');
-
-$t = new lime_test(1, new lime_output_color());
-
-$menuItem = Doctrine::getTable('MenuItem')->findOneBySlug('about');
-$t->is($menuItem->getBreadcrumbs()->getPathAsString(), 'Home / About');
\ No newline at end of file
Added: plugins/sfSympalPlugin/trunk/tests/unit/ConfigTest.php
===================================================================
--- plugins/sfSympalPlugin/trunk/tests/unit/ConfigTest.php
(rev 0)
+++ plugins/sfSympalPlugin/trunk/tests/unit/ConfigTest.php 2009-05-12
17:29:33 UTC (rev 18181)
@@ -0,0 +1,33 @@
+<?php
+
+$app = 'sympal';
+require_once(dirname(__FILE__).'/../bootstrap/unit.php');
+
+$t = new lime_test(9, new lime_output_color());
+
+sfSympalConfig::set('test', true);
+
+$t->is(sfSympalConfig::get('test'), true);
+
+sfSympalConfig::set('group', 'test', true);
+
+$t->is(sfSympalConfig::get('group', 'test'), true);
+
+$t->is(sfSympalConfig::get('doesnt_exists', null, 'default_value'),
'default_value');
+
+sfSympalConfig::writeSetting(null, 'test_write_value', 1);
+
+$path = sfConfig::get('sf_config_dir').'/app.yml';
+$array = (array) sfYaml::load(file_get_contents($path));
+$t->is(isset($array['all']['sympal_config']['test_write_value']), true);
+
+$t->is(sfSympalConfig::isI18nEnabled(), true);
+$t->is(sfSympalConfig::isVersioningEnabled(), true);
+$t->is(sfSympalConfig::isI18nEnabled('Content'), true);
+$t->is(sfSympalConfig::isVersioningEnabled('Content'), true);
+$t->is(sfSympalConfig::getVersionedModelOptions('Content'), array(
+ 'created_by',
+ 'is_published',
+ 'date_published',
+ 'slug'
+));
\ No newline at end of file
Added: plugins/sfSympalPlugin/trunk/tests/unit/ConfigurationTest.php
===================================================================
--- plugins/sfSympalPlugin/trunk/tests/unit/ConfigurationTest.php
(rev 0)
+++ plugins/sfSympalPlugin/trunk/tests/unit/ConfigurationTest.php
2009-05-12 17:29:33 UTC (rev 18181)
@@ -0,0 +1,70 @@
+<?php
+
+$app = 'sympal';
+require_once(dirname(__FILE__).'/../bootstrap/unit.php');
+
+$t = new lime_test(12, new lime_output_color());
+
+$sympalPluginConfiguration =
sfContext::getInstance()->getConfiguration()->getPluginConfiguration('sfSympalPlugin');
+$sympalConfiguration = $sympalPluginConfiguration->getSympalConfiguration();
+$t->is(get_class($sympalConfiguration), 'sympalSympalConfiguration');
+
+$requiredPlugins = array(
+ 'sfFormExtraPlugin',
+ 'sfTaskExtraPlugin',
+ 'sfFeed2Plugin',
+ 'sfWebBrowserPlugin',
+ 'sfSympalUserPlugin',
+ 'sfSympalMenuPlugin',
+ 'sfSympalPluginManagerPlugin',
+ 'sfSympalPagesPlugin',
+ 'sfSympalContentListPlugin',
+ 'sfSympalPlugin'
+);
+
+$t->is($sympalConfiguration->getRequiredPlugins(), $requiredPlugins);
+
+$corePlugins = array(
+ 'sfFormExtraPlugin',
+ 'sfTaskExtraPlugin',
+ 'sfFeed2Plugin',
+ 'sfWebBrowserPlugin',
+ 'sfSympalUserPlugin',
+ 'sfSympalMenuPlugin',
+ 'sfSympalPluginManagerPlugin',
+ 'sfSympalPagesPlugin',
+ 'sfSympalContentListPlugin',
+);
+
+$t->is($sympalConfiguration->getCorePlugins(), $corePlugins);
+
+$t->is($sympalConfiguration->getInstalledPlugins(), array());
+
+$addonPlugins = $sympalConfiguration->getAddonPlugins();
+$t->is(in_array('sfSympalBlogPlugin', $addonPlugins), true);
+$t->is(in_array('sfSympalJwageThemePlugin', $addonPlugins), true);
+
+$t->is($sympalConfiguration->getOtherPlugins(), array());
+
+$all = array(
+ 'sfSympalBlogPlugin',
+ 'sfSympalCommentsPlugin',
+ 'sfSympalDoctrineThemePlugin',
+ 'sfSympalJwageThemePlugin',
+ 'sfSympalOpenAuthPlugin',
+ 'sfSympalSlideshowPlugin',
+ 'sfSympalSocialFollowPlugin',
+ 'sfSympalTagsPlugin',
+);
+
+$t->is(in_array('sfSympalBlogPlugin', $all), true);
+$t->is(in_array('sfSympalJwageThemePlugin', $all), true);
+
+$pluginPaths = $sympalConfiguration->getPluginPaths();
+$t->is($pluginPaths['sfSympalPlugin'],
$sympalPluginConfiguration->getRootDir());
+
+$modules = $sympalConfiguration->getModules();
+$t->is(in_array('sympal_content_renderer', $modules), true);
+
+$layouts = $sympalConfiguration->getLayouts();
+$t->is(in_array('Sympal', $layouts), true);
\ No newline at end of file
Modified: plugins/sfSympalPlugin/trunk/tests/unit/ContentTest.php
===================================================================
--- plugins/sfSympalPlugin/trunk/tests/unit/ContentTest.php 2009-05-12
15:25:32 UTC (rev 18180)
+++ plugins/sfSympalPlugin/trunk/tests/unit/ContentTest.php 2009-05-12
17:29:33 UTC (rev 18181)
@@ -1,8 +1,9 @@
<?php
+
$app = 'sympal';
require_once(dirname(__FILE__).'/../bootstrap/unit.php');
-$t = new lime_test(34, new lime_output_color());
+$t = new lime_test(33, new lime_output_color());
$user = new User();
$user->first_name = 'test';
@@ -132,67 +133,6 @@
$t->is($slots[1]->render(), '<div class="sympal_markdown"><p>test</p>
</div>');
-$markdown = "
->**TIP**
->Testing tip
-
--
-
->**NOTE**
->Testing note
-
--
-
->**QUOTE**
->Testing quote
-
- [php]
- echo 'test';
-
--
-
- [yml]
- ---
- User:
- columns:
- username: string(255)
-";
-
-$html = '<div class="sympal_markdown"><blockquote class="tip"><p>
- Testing tip</p>
-</blockquote>
-
-
-
-<blockquote class="note"><p>
- Testing note</p>
-</blockquote>
-
-
-
-<blockquote class="quote"><p>
- Testing quote</p>
-</blockquote>
-
-<pre class="php"><span class="kw2"><?php</span>
-
-<span class="kw3">echo</span> <span class="st0">\'test\'</span>;
-
-<span class="kw2">?></span></pre>
-
-
-
-<pre><code class="yaml"><span class="yaml_top_dashes">---</span>
-<span class="yaml_keys">User</span><span class="yaml_colon">:</span>
-<span class="yaml_keys"> columns</span><span class="yaml_colon">:</span>
-<span class="yaml_keys"> username</span><span
class="yaml_colon">:</span><span class="yaml_string"> string(255)</span>
-</code></pre>
-</div>';
-
-$slots[1]['value'] = $markdown;
-
-$t->is($slots[1]->render(), $html);
-
$slots->save();
$t->is($slots[2]->render(), 'Body value<br />
Added: plugins/sfSympalPlugin/trunk/tests/unit/DiffTest.php
===================================================================
--- plugins/sfSympalPlugin/trunk/tests/unit/DiffTest.php
(rev 0)
+++ plugins/sfSympalPlugin/trunk/tests/unit/DiffTest.php 2009-05-12
17:29:33 UTC (rev 18181)
@@ -0,0 +1,12 @@
+<?php
+
+require_once(dirname(__FILE__).'/../bootstrap/unit.php');
+
+$t = new lime_test(1, new lime_output_color());
+
+$from = 'This is the from text';
+$to = 'This is the to text that we are going to run a diff against.';
+
+$diff = new sfSympalDiff($from, $to);
+
+$t->is((string) $diff, "This is the <del>from</del><ins>to</ins> text<ins>
that we are going to run a diff against.</ins>\n");
\ No newline at end of file
Added: plugins/sfSympalPlugin/trunk/tests/unit/EmailTest.php
===================================================================
--- plugins/sfSympalPlugin/trunk/tests/unit/EmailTest.php
(rev 0)
+++ plugins/sfSympalPlugin/trunk/tests/unit/EmailTest.php 2009-05-12
17:29:33 UTC (rev 18181)
@@ -0,0 +1,35 @@
+<?php
+
+require_once(dirname(__FILE__).'/../bootstrap/unit.php');
+
+$t = new lime_test(6, new lime_output_color());
+
+class sfSympalMailTest extends sfSympalMail
+{
+ public function send($emailAddress = null, $fromAddress = null)
+ {
+
+ }
+}
+
+$email = new sfSympalMailTest();
+$email->setEmailAddress('[email protected]');
+$email->setFromAddress('[email protected]');
+$email->setMessage('Test subject', 'Test body');
+
+$t->is($email->getMessage() instanceof Swift_Message, true);
+$t->is($email->getMessage()->getSubject(), 'Test subject');
+$t->is($email->getMessage()->getBody(), 'Test body');
+
+// forwarding
+$t->is($email->getOptions(), 0);
+$t->is($email->connection instanceof Swift_Connection_NativeMail, true);
+
+class TestConn extends Swift_Connection_NativeMail
+{
+
+}
+
+$conn = new TestConn();
+$email->connection = $conn;
+$t->is($email->connection instanceof TestConn, true);
\ No newline at end of file
Added: plugins/sfSympalPlugin/trunk/tests/unit/EventsTest.php
===================================================================
--- plugins/sfSympalPlugin/trunk/tests/unit/EventsTest.php
(rev 0)
+++ plugins/sfSympalPlugin/trunk/tests/unit/EventsTest.php 2009-05-12
17:29:33 UTC (rev 18181)
@@ -0,0 +1,6 @@
+<?php
+
+$app = 'sympal';
+require_once(dirname(__FILE__).'/../bootstrap/unit.php');
+
+$t = new lime_test(0, new lime_output_color());
\ No newline at end of file
Added: plugins/sfSympalPlugin/trunk/tests/unit/HelperTest.php
===================================================================
--- plugins/sfSympalPlugin/trunk/tests/unit/HelperTest.php
(rev 0)
+++ plugins/sfSympalPlugin/trunk/tests/unit/HelperTest.php 2009-05-12
17:29:33 UTC (rev 18181)
@@ -0,0 +1,28 @@
+<?php
+
+$app = 'sympal';
+require_once(dirname(__FILE__).'/../bootstrap/unit.php');
+
+$t = new lime_test(6, new lime_output_color());
+
+$browser = new sfTestFunctional(new sfBrowser());
+$browser->get('/');
+
+$menuItem = Doctrine::getTable('MenuItem')->findOneBySlug('about');
+$t->is($menuItem->getBreadcrumbs()->getPathAsString(), 'Home / About');
+$t->is(get_sympal_breadcrumbs($menuItem), '<div id="sympal_breadcrumbs"><ul
id="breadcrumbs-menu"><li id="breadcrumbs-home"><a
href="/index.php/">Home</a></li><li
id="breadcrumbs-about">About</li></ul></div>');
+
+$breadcrumbs = array(
+ 'Home' => '@homepage',
+ 'About' => 'http://www.google.com',
+ 'Jonathan H. Wage' => 'http://www.jwage.com'
+);
+$t->is(get_sympal_breadcrumbs($breadcrumbs), '<div id="sympal_breadcrumbs"><ul
id="breadcrumbs-menu"><li id="breadcrumbs-home"><a
href="/index.php/">Home</a></li><li id="breadcrumbs-about"><a
href="http://www.google.com">About</a></li><li
id="breadcrumbs-jonathan-h-wage">Jonathan H. Wage</li></ul></div>');
+
+$t->is(get_sympal_yui_path('css', 'menu/assets/skins/sam/menu'),
'/sfSympalPlugin/yui/menu/assets/skins/sam/menu');
+$t->is(get_sympal_yui_path('js', 'animation/animation'),
'/sfSympalPlugin/yui/animation/animation-min');
+
+$orig = sfConfig::get('sf_debug');
+sfConfig::set('sf_debug', false);
+$t->is(get_sympal_yui_path('js', 'animation/animation'),
'/sfSympalPlugin/yui/animation/animation');
+sfConfig::set('sf_debug', $orig);
\ No newline at end of file
Added: plugins/sfSympalPlugin/trunk/tests/unit/MarkdownTest.php
===================================================================
--- plugins/sfSympalPlugin/trunk/tests/unit/MarkdownTest.php
(rev 0)
+++ plugins/sfSympalPlugin/trunk/tests/unit/MarkdownTest.php 2009-05-12
17:29:33 UTC (rev 18181)
@@ -0,0 +1,65 @@
+<?php
+
+$app = 'sympal';
+require_once(dirname(__FILE__).'/../bootstrap/unit.php');
+
+$t = new lime_test(1, new lime_output_color());
+
+$markdown = "
+>**TIP**
+>Testing tip
+
+-
+
+>**NOTE**
+>Testing note
+
+-
+
+>**QUOTE**
+>Testing quote
+
+ [php]
+ echo 'test';
+
+-
+
+ [yml]
+ ---
+ User:
+ columns:
+ username: string(255)
+";
+
+$html = '<div class="sympal_markdown"><blockquote class="tip"><p>
+ Testing tip</p>
+</blockquote>
+
+
+
+<blockquote class="note"><p>
+ Testing note</p>
+</blockquote>
+
+
+
+<blockquote class="quote"><p>
+ Testing quote</p>
+</blockquote>
+
+<pre class="php"><span class="kw2"><?php</span>
+
+<span class="kw3">echo</span> <span class="st0">\'test\'</span>;
+
+<span class="kw2">?></span></pre>
+
+
+
+<pre><code class="yaml"><span class="yaml_top_dashes">---</span>
+<span class="yaml_keys">User</span><span class="yaml_colon">:</span>
+<span class="yaml_keys"> columns</span><span class="yaml_colon">:</span>
+<span class="yaml_keys"> username</span><span
class="yaml_colon">:</span><span class="yaml_string"> string(255)</span>
+</code></pre>
+</div>';
+
+$t->is(sfSympalMarkdownRenderer::convertToHtml($markdown), $html);
\ No newline at end of file
Modified: plugins/sfSympalPlugin/trunk/tests/unit/MenuItemTest.php
===================================================================
--- plugins/sfSympalPlugin/trunk/tests/unit/MenuItemTest.php 2009-05-12
15:25:32 UTC (rev 18180)
+++ plugins/sfSympalPlugin/trunk/tests/unit/MenuItemTest.php 2009-05-12
17:29:33 UTC (rev 18181)
@@ -1,4 +1,5 @@
<?php
+
$app = 'sympal';
require_once(dirname(__FILE__).'/../bootstrap/unit.php');
Modified: plugins/sfSympalPlugin/trunk/tests/unit/MenuTest.php
===================================================================
--- plugins/sfSympalPlugin/trunk/tests/unit/MenuTest.php 2009-05-12
15:25:32 UTC (rev 18180)
+++ plugins/sfSympalPlugin/trunk/tests/unit/MenuTest.php 2009-05-12
17:29:33 UTC (rev 18181)
@@ -1,4 +1,5 @@
<?php
+
$app = 'sympal';
require_once(dirname(__FILE__).'/../bootstrap/unit.php');
Modified: plugins/sfSympalPlugin/trunk/tests/unit/PluginManager1Test.php
===================================================================
--- plugins/sfSympalPlugin/trunk/tests/unit/PluginManager1Test.php
2009-05-12 15:25:32 UTC (rev 18180)
+++ plugins/sfSympalPlugin/trunk/tests/unit/PluginManager1Test.php
2009-05-12 17:29:33 UTC (rev 18181)
@@ -1,4 +1,5 @@
<?php
+
$app = 'sympal';
require_once(dirname(__FILE__).'/../bootstrap/unit.php');
Modified: plugins/sfSympalPlugin/trunk/tests/unit/PluginManager2Test.php
===================================================================
--- plugins/sfSympalPlugin/trunk/tests/unit/PluginManager2Test.php
2009-05-12 15:25:32 UTC (rev 18180)
+++ plugins/sfSympalPlugin/trunk/tests/unit/PluginManager2Test.php
2009-05-12 17:29:33 UTC (rev 18181)
@@ -1,4 +1,5 @@
<?php
+
$app = 'sympal';
require_once(dirname(__FILE__).'/../bootstrap/unit.php');
Added: plugins/sfSympalPlugin/trunk/tests/unit/ToolkitsTest.php
===================================================================
--- plugins/sfSympalPlugin/trunk/tests/unit/ToolkitsTest.php
(rev 0)
+++ plugins/sfSympalPlugin/trunk/tests/unit/ToolkitsTest.php 2009-05-12
17:29:33 UTC (rev 18181)
@@ -0,0 +1,37 @@
+<?php
+
+$app = 'sympal';
+require_once(dirname(__FILE__).'/../bootstrap/unit.php');
+
+$t = new lime_test(7, new lime_output_color());
+
+$menuItem = Doctrine::getTable('MenuItem')->findOneBySlug('about');
+sfSympalToolkit::setCurrentMenuItem($menuItem);
+
+$t->is(sfSympalToolkit::getCurrentMenuItem(), $menuItem);
+$t->is(sfSympalToolkit::getCurrentSite()->getSlug(), $app);
+
+$resource = sfSympalToolkit::getSymfonyResource('test', 'email', array(
+ 'variable' => 'Variable 1',
+ 'variable2' => 'Variable 2'
+));
+$t->is($resource, 'Subject
+Body Variable 1 Variable 2');
+
+$t->is(sfSympalToolkit::getFirstApplication(), 'sympal');
+
+$template = "
+##test/test##
+<?php echo 'Testing' ?>
+";
+$t->is(sfSympalToolkit::processTemplate($template), 'Test
+Testing');
+
+$template = "##test/email##";
+$t->is(sfSympalToolkit::processTemplate($template, array(
+ 'variable' => 'Variable 1',
+ 'variable2' => 'Variable 2'
+)), 'Subject
+Body Variable 1 Variable 2');
+
+$t->is(in_array('en', sfSympalToolkit::getAllLanguageCodes()), true);
\ No newline at end of file
Added: plugins/sfSympalPlugin/trunk/tests/unit/UserSessionTest.php
===================================================================
--- plugins/sfSympalPlugin/trunk/tests/unit/UserSessionTest.php
(rev 0)
+++ plugins/sfSympalPlugin/trunk/tests/unit/UserSessionTest.php 2009-05-12
17:29:33 UTC (rev 18181)
@@ -0,0 +1,45 @@
+<?php
+
+$app = 'sympal';
+require_once(dirname(__FILE__).'/../bootstrap/unit.php');
+
+$t = new lime_test(14, new lime_output_color());
+
+$user = sfContext::getInstance()->getUser();
+$content = Doctrine::getTable('Content')
+ ->getTypeQuery('Page')
+ ->andWhere('c.slug = ?', 'home')
+ ->fetchOne();
+
+$t->is($user->hasAccessToContent($content), true);
+
+$content->Permissions[] =
Doctrine::getTable('Permission')->findOneByName('ManageContent');
+$content->save();
+
+$admin = Doctrine::getTable('User')->findOneByIsSuperAdmin(1);
+$user->signIn($admin);
+
+$t->is($user->hasAccessToContent($content), true);
+$t->is($user->isEditMode(), true);
+
+$user->toggleEditMode();
+$t->is($user->isEditMode(), false);
+
+$user->toggleEditMode();
+$t->is($user->isEditMode(), true);
+
+$user->obtainContentLock($content);
+
+$t->is($content->locked_by, $admin->id);
+$t->is($user->getOpenContentLock()->id, $content->id);
+$user->releaseOpenLock();
+
+$content->refresh();
+$t->is($content->locked_by, null);
+
+$t->is($user->isSuperAdmin(), true);
+$t->is($user->isAnonymous(), false);
+$t->is($user->hasCredential('BlahSomethingFake'), true);
+$t->is($user->getSympalUser()->id, $admin->id);
+$t->is((string) $user, 'Sympal Admin');
+$t->is($user->checkPassword('admin'), true);
\ No newline at end of file
Modified: plugins/sfSympalPlugin/trunk/tests/unit/VersionTest.php
===================================================================
--- plugins/sfSympalPlugin/trunk/tests/unit/VersionTest.php 2009-05-12
15:25:32 UTC (rev 18180)
+++ plugins/sfSympalPlugin/trunk/tests/unit/VersionTest.php 2009-05-12
17:29:33 UTC (rev 18181)
@@ -1,4 +1,5 @@
<?php
+
$app = 'sympal';
require_once(dirname(__FILE__).'/../bootstrap/unit.php');
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"symfony SVN" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/symfony-svn?hl=en
-~----------~----~----~----~------~----~------~--~---