Use postgresql for travis #62
5 changed files with 126 additions and 30 deletions
13
.travis.yml
13
.travis.yml
|
@ -1,8 +1,17 @@
|
||||||
language: php
|
language: php
|
||||||
|
|
||||||
php:
|
php:
|
||||||
- '5.6'
|
- '5.6'
|
||||||
- '7.0'
|
- '7.0'
|
||||||
|
|
||||||
|
services:
|
||||||
|
- postgresql
|
||||||
|
|
||||||
install:
|
install:
|
||||||
- composer install
|
- composer install
|
||||||
script: bin/phpunit -c app
|
|
||||||
before_script: phpenv config-add .travis-php-config.ini
|
before_script:
|
||||||
|
- psql -c 'create database travis_ci_test;' -U postgres
|
||||||
|
- cp app/config/config_travis.yml app/config/config_test.yml
|
||||||
|
|
||||||
|
script: bin/phpunit --verbose -c app
|
||||||
|
|
|
@ -34,4 +34,11 @@ class AppKernel extends Kernel
|
||||||
{
|
{
|
||||||
$loader->load(__DIR__.'/config/config_'.$this->getEnvironment().'.yml');
|
$loader->load(__DIR__.'/config/config_'.$this->getEnvironment().'.yml');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function __construct($environment, $debug)
|
||||||
|
{
|
||||||
|
date_default_timezone_set( 'Europe/Berlin' );
|
||||||
|
parent::__construct($environment, $debug);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,8 +19,10 @@ liip_functional_test: ~
|
||||||
|
|
||||||
doctrine:
|
doctrine:
|
||||||
dbal:
|
dbal:
|
||||||
default_connection: default
|
driver: "pdo_pgsql"
|
||||||
connections:
|
host: "localhost"
|
||||||
default:
|
port: "5432"
|
||||||
driver: pdo_sqlite
|
dbname: "travis_ci_test"
|
||||||
path: %kernel.cache_dir%/test.db
|
user: "postgres"
|
||||||
|
password: "123456"
|
||||||
|
charset: UTF8
|
28
app/config/config_travis.yml
Normal file
28
app/config/config_travis.yml
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
imports:
|
||||||
|
- { resource: config_dev.yml }
|
||||||
|
|
||||||
|
framework:
|
||||||
|
test: ~
|
||||||
|
session:
|
||||||
|
storage_id: session.storage.mock_file
|
||||||
|
profiler:
|
||||||
|
collect: false
|
||||||
|
|
||||||
|
web_profiler:
|
||||||
|
toolbar: false
|
||||||
|
intercept_redirects: false
|
||||||
|
|
||||||
|
swiftmailer:
|
||||||
|
disable_delivery: true
|
||||||
|
|
||||||
|
liip_functional_test: ~
|
||||||
|
|
||||||
|
doctrine:
|
||||||
|
dbal:
|
||||||
|
driver: "pdo_pgsql"
|
||||||
|
host: "localhost"
|
||||||
|
port: "5432"
|
||||||
|
dbname: "travis_ci_test"
|
||||||
|
user: "postgres"
|
||||||
|
password: ""
|
||||||
|
charset: UTF8
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
namespace Hackspace\Bundle\CalciferBundle\Tests\Controller;
|
namespace Hackspace\Bundle\CalciferBundle\Tests\Controller;
|
||||||
|
|
||||||
|
use Doctrine\Bundle\DoctrineBundle\Registry;
|
||||||
use Doctrine\ORM\Decorator\EntityManagerDecorator;
|
use Doctrine\ORM\Decorator\EntityManagerDecorator;
|
||||||
use Doctrine\ORM\EntityRepository;
|
use Doctrine\ORM\EntityRepository;
|
||||||
use Hackspace\Bundle\CalciferBundle\Entity\Event;
|
use Hackspace\Bundle\CalciferBundle\Entity\Event;
|
||||||
|
@ -9,23 +10,60 @@ use Liip\FunctionalTestBundle\Test\WebTestCase;
|
||||||
|
|
||||||
class EventControllerTest extends WebTestCase
|
class EventControllerTest extends WebTestCase
|
||||||
{
|
{
|
||||||
|
/** @var \DateTime */
|
||||||
|
private $now = null;
|
||||||
|
|
||||||
private function initClient() {
|
/** @var \DateTime */
|
||||||
$this->loadFixtures([]);
|
private $startdate = null;
|
||||||
|
|
||||||
|
/** @var \DateTime */
|
||||||
|
private $enddate = null;
|
||||||
|
|
||||||
|
const dateformat = "Y-m-d H:i";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* EventControllerTest constructor.
|
||||||
|
*/
|
||||||
|
public function __construct($name = null, array $data = [], $dataName = '')
|
||||||
|
{
|
||||||
|
parent::__construct($name,$data,$dataName);
|
||||||
|
$this->now = new \DateTime();
|
||||||
|
$this->now->setTime(0,0,0);
|
||||||
|
|
||||||
|
$tz = new \DateTimeZone("Europe/Berlin");
|
||||||
|
$this->now->setTimezone($tz);
|
||||||
|
|
||||||
|
$this->startdate = clone $this->now;
|
||||||
|
$this->startdate->add(new \DateInterval("P1D"));
|
||||||
|
$this->enddate = clone $this->now;
|
||||||
|
$this->enddate->add(new \DateInterval("P1DT2H"));
|
||||||
|
|
||||||
$client = static::makeClient();
|
|
||||||
return $client;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function runCommandStatic($name) {
|
||||||
|
$command = sprintf("php app/console %s", $name);
|
||||||
|
$output = "";
|
||||||
|
exec($command,$output);
|
||||||
|
return $output;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function setUpBeforeClass()
|
||||||
|
{
|
||||||
|
EventControllerTest::runCommandStatic("doctrine:database:drop --force --env=test");
|
||||||
|
EventControllerTest::runCommandStatic("doctrine:database:create --env=test");
|
||||||
|
EventControllerTest::runCommandStatic("doctrine:schema:create --env=test");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public function testEmptyListing() {
|
public function testEmptyListing() {
|
||||||
$client = $this->initClient();
|
$client = static::makeClient();
|
||||||
$crawler = $client->request('GET', '/');
|
$crawler = $client->request('GET', '/');
|
||||||
$this->assertStatusCode(200, $client);
|
$this->assertStatusCode(200, $client);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testPostEventForm()
|
public function testPostEventForm()
|
||||||
{
|
{
|
||||||
$client = $this->initClient();
|
$client = static::makeClient();
|
||||||
|
|
||||||
$url = $client->getContainer()->get('router')->generate('_new');
|
$url = $client->getContainer()->get('router')->generate('_new');
|
||||||
|
|
||||||
|
@ -34,19 +72,11 @@ class EventControllerTest extends WebTestCase
|
||||||
|
|
||||||
$form = $crawler->selectButton('save')->form();
|
$form = $crawler->selectButton('save')->form();
|
||||||
|
|
||||||
$now = new \DateTime();
|
|
||||||
$now->setTime(0,0,0);
|
|
||||||
|
|
||||||
$tz = new \DateTimeZone("Europe/Berlin");
|
|
||||||
$now->setTimezone($tz);
|
|
||||||
|
|
||||||
$dateformat = "Y-m-d H:i";
|
|
||||||
$startdate = clone $now;
|
$form['startdate'] = $this->startdate->format(EventControllerTest::dateformat);
|
||||||
$startdate->add(new \DateInterval("P1D"));
|
$form['enddate'] = $this->enddate->format(EventControllerTest::dateformat);
|
||||||
$enddate = clone $now;
|
|
||||||
$enddate->add(new \DateInterval("P1DT2H"));
|
|
||||||
$form['startdate'] = $startdate->format("Y-m-d H:i");
|
|
||||||
$form['enddate'] = $enddate->format("Y-m-d H:i");
|
|
||||||
$form['summary'] = "Testevent";
|
$form['summary'] = "Testevent";
|
||||||
$form['url'] = "https://calcifer.datenknoten.me";
|
$form['url'] = "https://calcifer.datenknoten.me";
|
||||||
$form["location"] = "Krautspace";
|
$form["location"] = "Krautspace";
|
||||||
|
@ -87,8 +117,8 @@ class EventControllerTest extends WebTestCase
|
||||||
|
|
||||||
$this->assertInstanceOf('Hackspace\Bundle\CalciferBundle\Entity\Event', $entity);
|
$this->assertInstanceOf('Hackspace\Bundle\CalciferBundle\Entity\Event', $entity);
|
||||||
|
|
||||||
$this->assertTrue($startdate == $entity->startdate, "Startdate equal");
|
$this->assertTrue($this->startdate == $entity->startdate, "Startdate equal");
|
||||||
$this->assertTrue($enddate == $entity->enddate, "Enddate equal");
|
$this->assertTrue($this->enddate == $entity->enddate, "Enddate equal");
|
||||||
$this->assertTrue($form["summary"]->getValue() == $entity->summary, "Summary equal");
|
$this->assertTrue($form["summary"]->getValue() == $entity->summary, "Summary equal");
|
||||||
$this->assertTrue($form["url"]->getValue() == $entity->url, "URL equal");
|
$this->assertTrue($form["url"]->getValue() == $entity->url, "URL equal");
|
||||||
$this->assertTrue($form["description"]->getValue() == $entity->description, "Description equal");
|
$this->assertTrue($form["description"]->getValue() == $entity->description, "Description equal");
|
||||||
|
@ -102,10 +132,17 @@ class EventControllerTest extends WebTestCase
|
||||||
$this->assertTrue($form["location_lat"]->getValue() == $entity->location->lat);
|
$this->assertTrue($form["location_lat"]->getValue() == $entity->location->lat);
|
||||||
$this->assertTrue($form["location_lon"]->getValue() == $entity->location->lon);
|
$this->assertTrue($form["location_lon"]->getValue() == $entity->location->lon);
|
||||||
|
|
||||||
|
$em->close();
|
||||||
|
|
||||||
|
/** @var Registry $doc */
|
||||||
|
$doc = $this->getContainer()->get('doctrine');
|
||||||
|
|
||||||
|
foreach($doc->getConnections() as $connection) {
|
||||||
|
$connection->close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testICS() {
|
public function testICS() {
|
||||||
$this->testPostEventForm();
|
|
||||||
|
|
||||||
$client = static::makeClient();
|
$client = static::makeClient();
|
||||||
|
|
||||||
|
@ -125,18 +162,31 @@ BEGIN:VEVENT
|
||||||
UID:https://localhost/termine/testevent
|
UID:https://localhost/termine/testevent
|
||||||
DTSTAMP;TZID=Europe/Berlin:20160627T000000
|
DTSTAMP;TZID=Europe/Berlin:20160627T000000
|
||||||
SUMMARY:Testevent
|
SUMMARY:Testevent
|
||||||
DTSTART;TZID=Europe/Berlin:20160628T000000
|
DTSTART:%s
|
||||||
DESCRIPTION:Testdescription
|
DESCRIPTION:Testdescription
|
||||||
URL;VALUE=URI:https://calcifer.datenknoten.me
|
URL;VALUE=URI:https://calcifer.datenknoten.me
|
||||||
CATEGORIES:foo,bar,krautspace
|
CATEGORIES:foo,bar,krautspace
|
||||||
DTEND;TZID=Europe/Berlin:20160628T020000
|
DTEND:%s
|
||||||
LOCATION:Krautspace
|
LOCATION:Krautspace
|
||||||
GEO:1;2
|
GEO:1;2
|
||||||
END:VEVENT
|
END:VEVENT
|
||||||
END:VCALENDAR
|
END:VCALENDAR
|
||||||
|
|
||||||
EOF;
|
EOF;
|
||||||
|
$new_tz = new \DateTimeZone("UTC");
|
||||||
|
$this->startdate->setTimezone($new_tz);
|
||||||
|
$this->enddate->setTimezone($new_tz);
|
||||||
|
$start = $this->startdate->format("Ymd") . "T" . $this->startdate->format("His") . "Z";
|
||||||
|
$end = $this->enddate->format("Ymd") . "T" . $this->enddate->format("His") . "Z";
|
||||||
|
|
||||||
$this->assertEquals($test_doc, $client->getResponse()->getContent());
|
$test_doc = sprintf($test_doc,$start,$end);
|
||||||
|
|
||||||
|
$content = $client->getResponse()->getContent();
|
||||||
|
|
||||||
|
$content = preg_replace('~\R~u', "\r\n", $content);
|
||||||
|
$test_doc = preg_replace('~\R~u', "\r\n", $test_doc);
|
||||||
|
|
||||||
|
$this->assertGreaterThan(0,strlen($content));
|
||||||
|
$this->assertEquals($test_doc, $content);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue