Skip to content

Commit

Permalink
Doing couple of scenario cycles about our entity
Browse files Browse the repository at this point in the history
$> vim behat.yml
We've enabled page showing in extension for more output
$> bin/behat --no-paths admissions/student_enrols_on_a_course.feature:6
We've ran scenario and it sais "No Bossa entity namespace"
$> vim app/config/config.yml
So we're adding configuration to the config.yml
$> bin/behat --no-paths admissions/student_enrols_on_a_course.feature:6
We're running scenario again to discover "Directory does not exist"
$> mkdir src/Bossa/Entity
So we've created it
$> bin/behat --no-paths admissions/student_enrols_on_a_course.feature:6
And then scenario started to complain about "No class"
$> bin/phpspec describe Bossa/Entity/Course
So we've described it
$> bin/phpspec run
And checked it. PHPSpec2 was nice enough to generate class for us
$> bin/behat --no-paths admissions/student_enrols_on_a_course.feature:6
Then Doctrine2 inside scenario, started to complain that there's no mapping
$> vim spec/Bossa/Entity/Course.php
So we've added entity mapping
$> bin/behat --no-paths admissions/student_enrols_on_a_course.feature:6
Then, scenario said "No primary key"
$> vim spec/Bossa/Entity/Course.php
So we've added getter for property and property example into spec
$> bin/phpspec run
And PHPSpec2 again was nice enough to generate method for us.
$> vim spec/Bossa/Entity/Course.php
We just needed to add property and its mapping.
$> bin/behat --no-paths admissions/student_enrols_on_a_course.feature:6
And we checked that we have no-Doctrine2 exception now

We're going couple of scenario exception cycles to completely get rid
of Doctrine exceptions. This is called "Change the message or make it
green".
  • Loading branch information
everzet committed Sep 14, 2012
1 parent dbda4ad commit 6cc34f1
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 0 deletions.
7 changes: 7 additions & 0 deletions app/config/config.yml
Expand Up @@ -49,6 +49,13 @@ doctrine:
orm: orm:
auto_generate_proxy_classes: %kernel.debug% auto_generate_proxy_classes: %kernel.debug%
auto_mapping: true auto_mapping: true
mappings:
Bossa:
type: annotation
is_bundle: false
dir: %kernel.root_dir%/../src/Bossa/Entity
prefix: Bossa\Entity\
alias: Bossa


# Swiftmailer Configuration # Swiftmailer Configuration
swiftmailer: swiftmailer:
Expand Down
2 changes: 2 additions & 0 deletions behat.yml
Expand Up @@ -2,5 +2,7 @@ default:
extensions: extensions:
Behat\MinkExtension\Extension: Behat\MinkExtension\Extension:
default_session: symfony2 default_session: symfony2
show_cmd: open %s
show_auto: true
Behat\Symfony2Extension\Extension: Behat\Symfony2Extension\Extension:
bundle: @BossaTrainingBundle bundle: @BossaTrainingBundle
18 changes: 18 additions & 0 deletions spec/Bossa/Entity/Course.php
@@ -0,0 +1,18 @@
<?php

namespace spec\Bossa\Entity;

use PHPSpec2\Specification;

class Course implements Specification
{
function it_should_exist()
{
$this->object->shouldNotBe(null);
}

function it_should_have_primary_key_which_is_null()
{
$this->course->getId()->shouldReturn(null);
}
}
23 changes: 23 additions & 0 deletions src/Bossa/Entity/Course.php
@@ -0,0 +1,23 @@
<?php

namespace Bossa\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
* @ORM\Entity
*/
class Course
{
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;

public function getId()
{
return $this->id;
}
}

0 comments on commit 6cc34f1

Please sign in to comment.