mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 07:03:49 +00:00
cs: Fix code style (safe rules only).
This commit is contained in:
@@ -1,126 +1,115 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Chill is a suite of a modules, Chill is a software for social workers
|
||||
* Copyright (C) 2014, Champs Libres Cooperative SCRLFS, <http://www.champs-libres.coop>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
/**
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\ReportBundle\Tests\Search;
|
||||
|
||||
use DateTime;
|
||||
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
||||
|
||||
/**
|
||||
* Test for report search
|
||||
* Test for report search.
|
||||
*
|
||||
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
||||
* @internal
|
||||
* @coversNothing
|
||||
*/
|
||||
class ReportSearchTest extends WebTestCase
|
||||
{
|
||||
|
||||
public function testSearchExpectedDefault()
|
||||
{
|
||||
$client = $this->getAuthenticatedClient();
|
||||
|
||||
$crawler = $client->request('GET', '/fr/search', array(
|
||||
'q' => '@report 2015-01-05'
|
||||
));
|
||||
|
||||
$this->assertTrue($client->getResponse()->isSuccessful());
|
||||
$this->assertRegExp('/Situation de logement/i', $crawler->text());
|
||||
}
|
||||
|
||||
public function testNamedSearch()
|
||||
{
|
||||
$client = $this->getAuthenticatedClient();
|
||||
|
||||
$crawler = $client->request('GET', '/fr/search', array(
|
||||
'q' => '@report '.(new \DateTime('tomorrow'))->format('Y-m-d'), //there should be any result for future. And future is tomorrow
|
||||
'name' => 'report'
|
||||
));
|
||||
|
||||
|
||||
$crawler = $client->request('GET', '/fr/search', [
|
||||
'q' => '@report ' . (new DateTime('tomorrow'))->format('Y-m-d'), //there should be any result for future. And future is tomorrow
|
||||
'name' => 'report',
|
||||
]);
|
||||
|
||||
$this->assertTrue($client->getResponse()->isSuccessful());
|
||||
}
|
||||
|
||||
|
||||
public function testSearchByDate()
|
||||
{
|
||||
$client = $this->getAuthenticatedClient();
|
||||
|
||||
$crawler = $client->request('GET', '/fr/search', array(
|
||||
'q' => '@report date:2015-01-05'
|
||||
));
|
||||
|
||||
|
||||
$crawler = $client->request('GET', '/fr/search', [
|
||||
'q' => '@report date:2015-01-05',
|
||||
]);
|
||||
|
||||
$this->assertTrue($client->getResponse()->isSuccessful());
|
||||
$this->assertRegExp('/Situation de logement/i', $crawler->text());
|
||||
}
|
||||
|
||||
|
||||
public function testSearchDoubleDate()
|
||||
{
|
||||
$client = $this->getAuthenticatedClient();
|
||||
|
||||
$crawler = $client->request('GET', '/fr/search', array(
|
||||
'q' => '@report date:2014-05-01 2014-05-06'
|
||||
));
|
||||
|
||||
|
||||
$crawler = $client->request('GET', '/fr/search', [
|
||||
'q' => '@report date:2014-05-01 2014-05-06',
|
||||
]);
|
||||
|
||||
$this->assertGreaterThan(0, $crawler->filter('.error')->count());
|
||||
}
|
||||
|
||||
|
||||
public function testSearchEmtpy()
|
||||
{
|
||||
$client = $this->getAuthenticatedClient();
|
||||
|
||||
$crawler = $client->request('GET', '/fr/search', array(
|
||||
'q' => '@report '
|
||||
));
|
||||
|
||||
|
||||
$crawler = $client->request('GET', '/fr/search', [
|
||||
'q' => '@report ',
|
||||
]);
|
||||
|
||||
$this->assertGreaterThan(0, $crawler->filter('.error')->count());
|
||||
}
|
||||
|
||||
|
||||
public function testSearchExpectedDefault()
|
||||
{
|
||||
$client = $this->getAuthenticatedClient();
|
||||
|
||||
$crawler = $client->request('GET', '/fr/search', [
|
||||
'q' => '@report 2015-01-05',
|
||||
]);
|
||||
|
||||
$this->assertTrue($client->getResponse()->isSuccessful());
|
||||
$this->assertRegExp('/Situation de logement/i', $crawler->text());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that the user do not see unauthorized results
|
||||
*
|
||||
* We test for that that :
|
||||
* Test that the user do not see unauthorized results.
|
||||
*
|
||||
* We test for that that :
|
||||
* - we do not see any unauthorized scope mention
|
||||
*/
|
||||
public function testUsersDoNotSeeUnauthorizedResults()
|
||||
{
|
||||
$clientSocial = $this->getAuthenticatedClient();
|
||||
$clientAdministrative = $this->getAuthenticatedClient('center a_administrative');
|
||||
|
||||
$params = array('q' => '@report date:2015-01-05');
|
||||
|
||||
|
||||
$params = ['q' => '@report date:2015-01-05'];
|
||||
|
||||
$crawlerSocial = $clientSocial->request('GET', '/fr/search', $params);
|
||||
$crawlerAdministrative = $clientAdministrative->request('GET', '/fr/search', $params);
|
||||
|
||||
|
||||
|
||||
$this->assertNotContains('social', $crawlerAdministrative->filter('.content')
|
||||
->text());
|
||||
->text());
|
||||
$this->assertNotContains('administrative', $crawlerAdministrative->filter('.content')
|
||||
->text());
|
||||
->text());
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param mixed $username
|
||||
*
|
||||
* @return \Symfony\Component\BrowserKit\Client
|
||||
*/
|
||||
private function getAuthenticatedClient($username = 'center a_social')
|
||||
{
|
||||
return static::createClient(array(), array(
|
||||
'PHP_AUTH_USER' => $username,
|
||||
'PHP_AUTH_PW' => 'password',
|
||||
));
|
||||
return static::createClient([], [
|
||||
'PHP_AUTH_USER' => $username,
|
||||
'PHP_AUTH_PW' => 'password',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user