Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fix travis errors

  • Loading branch information...
commit a70eab445f2999f727843dd6a30610b72c20a513 1 parent ebd4ff5
@fpondepeyre authored Florian Pondepeyre committed
View
1  .gitignore
@@ -1,5 +1,4 @@
web/bundles/
-app/config/parameters.yml
app/bootstrap.php.cache
app/cache/*
app/logs/*
View
9 .travis.yml
@@ -1,10 +1,15 @@
language: php
php:
- - 5.3
+ - 5.3.3
+
+services: mysql
before_script:
+ - mysql -e 'create database dive_express_test;'
- curl -s http://getcomposer.org/installer | php
- php composer.phar install
-script: phpunit
+script:
+ - ./build-test.sh
+ - phpunit
View
7 README.md
@@ -1,5 +1,4 @@
-dive-express
-============
-
-dive express
+README
+======
+[![Build Status](https://secure.travis-ci.org/fpondepeyre/dive-express.png)](http://travis-ci.org/fpondepeyre/dive-express)
View
1  app/AppKernel.php
@@ -14,7 +14,6 @@ public function registerBundles()
new Symfony\Bundle\MonologBundle\MonologBundle(),
new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(),
new Symfony\Bundle\AsseticBundle\AsseticBundle(),
- new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
new JMS\AopBundle\JMSAopBundle(),
new JMS\DiExtraBundle\JMSDiExtraBundle($this),
View
15 app/config/config.yml
@@ -35,21 +35,6 @@ assetic:
#yui_css:
# jar: %kernel.root_dir%/Resources/java/yuicompressor-2.4.7.jar
-# Doctrine Configuration
-doctrine:
- dbal:
- driver: %database_driver%
- host: %database_host%
- port: %database_port%
- dbname: %database_name%
- user: %database_user%
- password: %database_password%
- charset: UTF8
-
- orm:
- auto_generate_proxy_classes: %kernel.debug%
- auto_mapping: true
-
# Propel Configuration
propel:
dbal:
View
1  app/config/config_test.yml
@@ -1,5 +1,6 @@
imports:
- { resource: config_dev.yml }
+ - { resource: parameters_test.yml }
framework:
test: ~
View
2  app/config/parameters.yml-dist → app/config/parameters.yml
@@ -2,7 +2,7 @@ parameters:
database_driver: pdo_mysql
database_host: localhost
database_port: null
- database_name: dive-express
+ database_name: dive_express
database_user: root
database_password: null
View
15 app/config/parameters_test.yml
@@ -0,0 +1,15 @@
+parameters:
+ database_driver: pdo_mysql
+ database_host: localhost
+ database_port: null
+ database_name: dive_express_test
+ database_user: root
+ database_password: null
+
+ mailer_transport: smtp
+ mailer_host: localhost
+ mailer_user: null
+ mailer_password: null
+
+ locale: en
+ secret: 8e7b410d110a7dcc438b42e34ab353064e
View
19 build-test.sh
@@ -0,0 +1,19 @@
+#!/bin/sh
+set -xe
+
+# Symlink assets
+php app/console assets:install web --symlink
+
+# Rebuild propel default
+php app/console propel:database:drop --force --connection=default --env=test
+php app/console propel:database:create --connection=default --env=test
+
+# Rebuild propel models
+php app/console propel:build --classes
+
+# Insert propel sql
+php app/console propel:sql:build --env=test
+php app/console propel:sql:insert --force --connection=default --env=test
+# php app/console propel:fixtures:load --connection=default --env=test
+
+php app/console cache:warmup --env=test
View
0  rebuild.sh → build.sh
File renamed without changes
View
2  composer.json
@@ -7,8 +7,6 @@
"require": {
"php": ">=5.3.3",
"symfony/symfony": "2.1.x-dev",
- "doctrine/orm": ">=2.2.3,<2.4-dev",
- "doctrine/doctrine-bundle": "1.0.*",
"twig/extensions": "1.0.*",
"symfony/assetic-bundle": "2.1.*",
"symfony/swiftmailer-bundle": "2.1.*",
View
219 composer.lock
@@ -1,5 +1,5 @@
{
- "hash": "f326f19817a75cf98dbd149595623ee6",
+ "hash": "7dda8baba26aa34c35a0b838632e92ec",
"packages": [
{
"name": "dflydev/markdown",
@@ -129,205 +129,6 @@
"time": "1348120518"
},
{
- "name": "doctrine/dbal",
- "version": "2.3.x-dev",
- "source": {
- "type": "git",
- "url": "https://github.com/doctrine/dbal",
- "reference": "fdc866a37959e43620e4f7ec519dc7dd8e30fc5b"
- },
- "dist": {
- "type": "zip",
- "url": "https://github.com/doctrine/dbal/zipball/fdc866a37959e43620e4f7ec519dc7dd8e30fc5b",
- "reference": "fdc866a37959e43620e4f7ec519dc7dd8e30fc5b",
- "shasum": ""
- },
- "require": {
- "php": ">=5.3.2",
- "doctrine/common": "2.3.*"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "2.3.x-dev"
- }
- },
- "installation-source": "source",
- "autoload": {
- "psr-0": {
- "Doctrine\\DBAL": "lib/"
- }
- },
- "license": [
- "MIT"
- ],
- "authors": [
- {
- "name": "Jonathan Wage",
- "email": "jonwage@gmail.com",
- "homepage": "http://www.jwage.com/"
- },
- {
- "name": "Guilherme Blanco",
- "email": "guilhermeblanco@gmail.com"
- },
- {
- "name": "Roman Borschel",
- "email": "roman@code-factory.org"
- },
- {
- "name": "Benjamin Eberlei",
- "email": "kontakt@beberlei.de"
- }
- ],
- "description": "Database Abstraction Layer",
- "homepage": "http://www.doctrine-project.org",
- "keywords": [
- "database",
- "persistence",
- "dbal",
- "queryobject"
- ],
- "time": "1348120597"
- },
- {
- "name": "doctrine/doctrine-bundle",
- "version": "dev-master",
- "target-dir": "Doctrine/Bundle/DoctrineBundle",
- "source": {
- "type": "git",
- "url": "git://github.com/doctrine/DoctrineBundle.git",
- "reference": "d3c930599723c8343472a5791b0f5909a4111a73"
- },
- "dist": {
- "type": "zip",
- "url": "https://github.com/doctrine/DoctrineBundle/zipball/d3c930599723c8343472a5791b0f5909a4111a73",
- "reference": "d3c930599723c8343472a5791b0f5909a4111a73",
- "shasum": ""
- },
- "require": {
- "php": ">=5.3.2",
- "doctrine/dbal": ">=2.2,<2.4-dev",
- "symfony/framework-bundle": "2.1.*",
- "symfony/doctrine-bridge": "2.1.*"
- },
- "require-dev": {
- "doctrine/orm": ">=2.2,<2.4-dev",
- "symfony/validator": "2.1.*",
- "symfony/yaml": "2.1.*"
- },
- "suggest": {
- "doctrine/orm": "The Doctrine ORM integration is optional in the bundle."
- },
- "type": "symfony-bundle",
- "extra": {
- "branch-alias": {
- "dev-master": "1.0.x-dev"
- }
- },
- "installation-source": "source",
- "autoload": {
- "psr-0": {
- "Doctrine\\Bundle\\DoctrineBundle": ""
- }
- },
- "license": [
- "MIT"
- ],
- "authors": [
- {
- "name": "Fabien Potencier",
- "email": "fabien@symfony.com"
- },
- {
- "name": "Symfony Community",
- "homepage": "http://symfony.com/contributors"
- },
- {
- "name": "Benjamin Eberlei",
- "email": "kontakt@beberlei.de"
- }
- ],
- "description": "Symfony DoctrineBundle",
- "homepage": "http://www.doctrine-project.org",
- "keywords": [
- "database",
- "orm",
- "persistence",
- "dbal"
- ],
- "time": "1347289964"
- },
- {
- "name": "doctrine/orm",
- "version": "2.3.x-dev",
- "source": {
- "type": "git",
- "url": "git://github.com/doctrine/doctrine2.git",
- "reference": "ea2b28857830720460a345c80c6e7d3f6adae93a"
- },
- "dist": {
- "type": "zip",
- "url": "https://github.com/doctrine/doctrine2/zipball/ea2b28857830720460a345c80c6e7d3f6adae93a",
- "reference": "ea2b28857830720460a345c80c6e7d3f6adae93a",
- "shasum": ""
- },
- "require": {
- "php": ">=5.3.2",
- "ext-pdo": "*",
- "symfony/console": "2.*",
- "doctrine/dbal": "2.3.*"
- },
- "suggest": {
- "symfony/yaml": "If you want to use YAML Metadata Mapping Driver"
- },
- "bin": [
- "bin/doctrine",
- "bin/doctrine.php"
- ],
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "2.3.x-dev"
- }
- },
- "installation-source": "source",
- "autoload": {
- "psr-0": {
- "Doctrine\\ORM": "lib/"
- }
- },
- "license": [
- "MIT"
- ],
- "authors": [
- {
- "name": "Jonathan Wage",
- "email": "jonwage@gmail.com",
- "homepage": "http://www.jwage.com/"
- },
- {
- "name": "Guilherme Blanco",
- "email": "guilhermeblanco@gmail.com"
- },
- {
- "name": "Roman Borschel",
- "email": "roman@code-factory.org"
- },
- {
- "name": "Benjamin Eberlei",
- "email": "kontakt@beberlei.de"
- }
- ],
- "description": "Object-Relational-Mapper for PHP",
- "homepage": "http://www.doctrine-project.org",
- "keywords": [
- "database",
- "orm"
- ],
- "time": "1348121015"
- },
- {
"name": "friendsofsymfony/rest",
"version": "dev-master",
"target-dir": "FOS/Rest",
@@ -385,12 +186,12 @@
"source": {
"type": "git",
"url": "https://github.com/FriendsOfSymfony/FOSRestBundle",
- "reference": "2cd153030041b3b817193bb8c64e980b9e7143e9"
+ "reference": "aa6ffaea436396c8079b8e6f40b2bc78d4a908c9"
},
"dist": {
"type": "zip",
- "url": "https://github.com/FriendsOfSymfony/FOSRestBundle/zipball/2cd153030041b3b817193bb8c64e980b9e7143e9",
- "reference": "2cd153030041b3b817193bb8c64e980b9e7143e9",
+ "url": "https://github.com/FriendsOfSymfony/FOSRestBundle/zipball/aa6ffaea436396c8079b8e6f40b2bc78d4a908c9",
+ "reference": "aa6ffaea436396c8079b8e6f40b2bc78d4a908c9",
"shasum": ""
},
"require": {
@@ -404,6 +205,7 @@
"symfony/form": ">=2.0,<2.3-dev",
"symfony/yaml": ">=2.0,<2.3-dev"
},
+ "time": "1348432329",
"type": "symfony-bundle",
"extra": {
"branch-alias": {
@@ -438,8 +240,7 @@
"homepage": "http://friendsofsymfony.github.com",
"keywords": [
"rest"
- ],
- "time": "1347997381"
+ ]
},
{
"name": "jms/aop-bundle",
@@ -507,7 +308,7 @@
"require": {
"php": ">=5.3.0"
},
- "time": "2012-01-02 10:40:52",
+ "time": "2012-01-02 09:40:52",
"type": "library",
"installation-source": "dist",
"autoload": {
@@ -614,7 +415,7 @@
"require": {
"php": ">=5.3.0"
},
- "time": "2012-01-02 11:32:49",
+ "time": "2012-01-02 10:32:49",
"type": "library",
"installation-source": "dist",
"autoload": {
@@ -738,7 +539,7 @@
"twig/twig": ">=1.8,<2.0-dev",
"doctrine/orm": ">=2.1,<2.4-dev"
},
- "time": "2012-09-20 09:23:52",
+ "time": "2012-09-20 07:23:52",
"type": "symfony-bundle",
"extra": {
"branch-alias": {
@@ -974,7 +775,7 @@
"require": {
"php": ">=5.2.0"
},
- "time": "2012-04-06 02:33:25",
+ "time": "2012-04-06 00:33:25",
"type": "library",
"installation-source": "dist",
"autoload": {
View
35 src/DiveExpress/ApiBundle/Controller/SpotController.php
@@ -12,6 +12,10 @@
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Nelmio\ApiDocBundle\Annotation\ApiDoc;
+use Symfony\Component\HttpFoundation\Request;
+use DiveExpress\ApiBundle\Form;
+use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
+
/**
* Spot controller.
*
@@ -75,8 +79,6 @@ public function getAction($id)
* return="DiveExpress\ApiBundle\Model\Spot"
* )
*
- * @Rest\View
- *
* @return \FOS\RestBundle\View\View|\Symfony\Component\HttpFoundation\Response
*/
public function newAction()
@@ -153,4 +155,33 @@ public function removeAction(Spot $spot)
{
$spot->delete();
}
+
+ /**
+ * SpotType form
+ *
+ * @param Request $request
+ *
+ * @Template()
+ *
+ * @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
+ */
+ public function formAction(Request $request)
+ {
+ $form = $this->createForm(new SpotType());
+
+ $formHandler = new \DiveExpress\ApiBundle\Form\SpotHandler($form, $request);
+
+ if ($formHandler->process()) {
+ return $this->redirect($this->generateUrl('form'));
+ }
+
+ return array(
+ 'form' => $form->createView()
+ );
+ }
}
+
+
+
+
+
View
60 src/DiveExpress/ApiBundle/Form/SpotHandler.php
@@ -0,0 +1,60 @@
+<?php
+
+namespace DiveExpress\ApiBundle\Form;
+
+use Symfony\Component\Form\Form;
+use Symfony\Component\HttpFoundation\Request;
+use DiveExpress\ApiBundle\Model\Spot;
+
+/**
+ * Spot handler
+ * This class process form
+ *
+ */
+class SpotHandler
+{
+ protected $form;
+ protected $request;
+
+ /**
+ * __construct method
+ *
+ * @param Form $form
+ * @param Request $request
+ */
+ public function __construct(Form $form, Request $request)
+ {
+ $this->form = $form;
+ $this->request = $request;
+ }
+
+ /**
+ * Process form
+ *
+ * @return bool
+ */
+ public function process()
+ {
+ if ($this->request->getMethod() == 'POST') {
+ $this->form->bind($this->request);
+ if ($this->form->isValid()) {
+ $this->onSuccess($this->form->getData());
+
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * Save the form
+ *
+ * @param Spot $spot
+ */
+ public function onSuccess(Spot $spot)
+ {
+ $spot->save();
+ }
+
+} //SpotHandler
View
4 src/DiveExpress/ApiBundle/Resources/config/routing.yml
@@ -35,3 +35,7 @@ api_spot_delete:
requirements:
_method: DELETE
id: "\d+"
+
+form:
+ pattern: /form
+ defaults: { _controller: DiveExpressApiBundle:Spot:form }
View
13 src/DiveExpress/ApiBundle/Resources/config/validation.yml
@@ -1,8 +1,9 @@
DiveExpress\ApiBundle\Model\Spot:
getters:
- title:
- - NotBlank:
- latitude:
- - NotBlank:
- longitude:
- - NotBlank:
+# title:
+# - NotBlank: ~
+# - MaxLength: 255
+# latitude:
+# - NotBlank: ~
+# longitude:
+# - NotBlank: ~
View
4 src/DiveExpress/ApiBundle/Resources/views/Spot/form.html.twig
@@ -0,0 +1,4 @@
+<form action="{{ path('form') }}" method="post" {{ form_enctype(form) }}>
+ {{ form_widget(form) }}
+ <input type="submit" />
+</form>
View
8 src/DiveExpress/ApiBundle/Tests/Controller/DefaultControllerTest.php
@@ -4,8 +4,16 @@
use DiveExpress\ApiBundle\Tests\DiveExpressWebTestCase;
+/**
+ * Tets DefaultController
+ *
+ */
class DefaultControllerTest extends DiveExpressWebTestCase
{
+ /**
+ * Test index action
+ *
+ */
public function testIndex()
{
$client = static::createClient();
View
79 src/DiveExpress/ApiBundle/Tests/Controller/SpotControllerTest.php
@@ -4,6 +4,7 @@
use DiveExpress\ApiBundle\Tests\DiveExpressWebTestCase;
use DiveExpress\ApiBundle\Model\Spot;
+
/**
* Test SpotController
*
@@ -11,45 +12,87 @@
class SpotControllerTest extends DiveExpressWebTestCase
{
/**
- * Test "/spots" url response
+ * Test "/spots" with GET
*
*/
public function testAllAction()
{
- $client = static::createClient();
+ $client = static::createClient();
$client->request('GET', '/spots');
$response = $client->getResponse();
$this->assertJsonResponse($response, 200);
- if ($profile = $client->getProfile()) {
- $this->assertLessThan(10, $profile->getCollector('db')->getQueryCount());
- $this->assertLessThan(2000, $profile->getCollector('time')->getTotalTime());
- }
}
/**
- * Test "/spots" url response
+ * Test "/spots" with POST
*
+ * curl -v -H "Accept: application/json" -H "Content-type: application/json" -X
+ * POST -d '{"spot": {"title": "Lorem ipsum", "longitude": 0.1234567, "latitude": 7.6543210}}'
+ * http://dive-express.local/app_dev.php/spots
*/
public function testNewAction()
{
- $this->markTestSkipped('@todo');
+ $json = '{"spot": {"title": "Lorem ipsum", "longitude": 0.1234567, "latitude": 7.6543210}}';
+
+ $client = static::createClient();
+ $client->request('POST','/spots', array(), array(), array('content_type' => 'application/json'), $json);
- $spot = new Spot();
- $spot->setTitle('Test');
- $spot->setLongitude(0.1234);
- $spot->setLatitude(0.1234);
- $spot->save();
+ $response = $client->getResponse();
- $client = static::createClient();
- $container = $client->getContainer();
- $serializer = $container->get('serializer');
- $jsonSpot = $serializer->serialize($spot, 'json');
+ $this->assertJsonResponse($response, 201);
+ }
+
+ /**
+ * Test "/spots/1" with GET
+ *
+ */
+ public function testGetAction()
+ {
+ $client = static::createClient();
+ $client->request('GET', '/spots/1');
- $client->request('POST', '/spots', array($jsonSpot));
$response = $client->getResponse();
$this->assertJsonResponse($response, 200);
}
+
+ /**
+ * Test /spots/1 with PUT
+ *
+ */
+ public function testEditAction()
+ {
+ $jsonSpot = '{"spot": {"title": "Lorem ipsum", "longitude": 0.1, "latitude": 7.6}}';
+
+ $client = static::createClient();
+ $client->request(
+ 'PUT',
+ '/spots/1',
+ array(),
+ array(),
+ array('CONTENT_TYPE' => 'application/json'),
+ $jsonSpot
+ );
+
+ $response = $client->getResponse();
+
+ $this->assertJsonResponse($response, 204);
+ }
+
+ /**
+ * Test "/spots/1" with DELETE
+ *
+ */
+ public function testRemoveAction()
+ {
+ $client = static::createClient();
+ $client->request('DELETE', '/spots/1');
+
+ $response = $client->getResponse();
+
+ $this->assertJsonResponse($response, 204);
+ }
}
+
Please sign in to comment.
Something went wrong with that request. Please try again.