<commit_before><?php
require_once(dirname(__FILE__).'/../bootstrap/functional.php');

$browser = new sfTestFunctional(new sfBrowser());
$browser->get('/');

$menuItems = Doctrine_Core::getTable('MenuItem')->findAll();
foreach ($menuItems as $menuItem)
{
  if ($menuItem->level <= 0 || $menuItem->requires_auth || $menuItem->requires_no_auth || !($content = $menuItem->getMainContent()))
  {
    continue;
  }

  $browser->
    click($menuItem->getLabel())->
    with('response')->begin()->
      isStatusCode('200')->
    end()->
    with('request')->begin()->
      isParameter('module', 'sympal_content_renderer')->
      isParameter('action', 'index')->
    end()
  ;
}

$browser->
  get('/security/signin')->
  post('/security/signin', array('signin' => array('username' => 'admin', 'password' => '<PASSWORD>')))->
  with('response')->begin()->
    isRedirected()->
    followRedirect()->
  end()->
  with('user')->begin()->
    isAuthenticated()->
  end()
;

$browser->
  get('/security/signout')->
  with('response')->begin()->
    isRedirected()->
    followRedirect()->
  end()
;

$browser->
  get('/register')->
  post('/register/save', array('user' => array('first_name' => 'Jonathan', 'last_name' => 'Wage', 'email_address' => '<EMAIL>', 'username' => 'test', 'password' => '<PASSWORD>', 'password_again' => '<PASSWORD>')))->
  with('response')->begin()->
    isRedirected()->
    followRedirect()->
  end()
;

$browser->
  click('Signout')->
  with('response')->begin()->
    isRedirected()->
    followRedirect()->
  end()->
  click('Signin')->
  post('/security/signin', array('signin' => array('username' => 'test', 'password' => '<PASSWORD>')))->
  with('user')->begin()->
    isAuthenticated()->
  end()
;<commit_msg>[1.4][sfSympalPlugin] Adding test for query count<commit_after><?php
require_once(dirname(__FILE__).'/../bootstrap/functional.php');

$browser = new sfTestFunctional(new sfBrowser());
$browser->get('/');

$menuItems = Doctrine_Core::getTable('MenuItem')->findAll();
foreach ($menuItems as $menuItem)
{
  if ($menuItem->level <= 0 || $menuItem->requires_auth || $menuItem->requires_no_auth || !($content = $menuItem->getMainContent()))
  {
    continue;
  }

  $browser->
    click($menuItem->getLabel())->
    with('response')->begin()->
      isStatusCode('200')->
    end()->
    with('request')->begin()->
      isParameter('module', 'sympal_content_renderer')->
      isParameter('action', 'index')->
    end()
  ;
}

$browser->
  get('/security/signin')->
  post('/security/signin', array('signin' => array('username' => 'admin', 'password' => '<PASSWORD>')))->
  with('response')->begin()->
    isRedirected()->
    followRedirect()->
  end()->
  with('user')->begin()->
    isAuthenticated()->
  end()
;

$browser->
  get('/security/signout')->
  with('response')->begin()->
    isRedirected()->
    followRedirect()->
  end()
;

$browser->
  get('/register')->
  post('/register/save', array('user' => array('first_name' => 'Jonathan', 'last_name' => 'Wage', 'email_address' => '<EMAIL>', 'username' => 'test', 'password' => '<PASSWORD>', 'password_again' => '<PASSWORD>')))->
  with('response')->begin()->
    isRedirected()->
    followRedirect()->
  end()
;

$browser->
  click('Signout')->
  with('response')->begin()->
    isRedirected()->
    followRedirect()->
  end()->
  click('Signin')->
  post('/security/signin', array('signin' => array('username' => 'test', 'password' => '<PASSWORD>')))->
  with('user')->begin()->
    isAuthenticated()->
  end()
;

$profiler = new Doctrine_Connection_Profiler();
$conn = Doctrine_Manager::connection();
$conn->addListener($profiler);

// Test base query count for pulling a page is 2
$browser->get('/pages/about');

$count = 0;
foreach ($profiler as $event)
{
  if ($event->getName() == 'execute')
  {
    $count++;
  }
}
$browser->test()->is($count, 4, 'Make sure we do not have more than 4 queries');
{'fraction_non_alphanumeric': 0.24788081171333162, 'fraction_numerical': 0.0035961983046493705, 'mean_word_length': 4.3124147339699865, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 150, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '112889', 'n_tokens_mistral': 1246, 'n_tokens_neox': 1232, 'n_words': 222}