Skip to content

Commit

Permalink
Add PHPSpec
Browse files Browse the repository at this point in the history
  • Loading branch information
alexislefebvre committed Sep 1, 2017
1 parent 8d45bb0 commit c14ad54
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .scrutinizer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ build:
idle_timeout: 900
tests:
override:
-
command: './vendor/bin/phpspec run --format=pretty'
-
command: './vendor/bin/phpunit --coverage-clover=coverage-clover'
coverage:
Expand Down
5 changes: 4 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ install:
- composer require --dev symfony/symfony:${SYMFONY_VERSION} $DEPENDENCY --no-update
- composer install --no-interaction --profile --no-progress

script: php ./vendor/bin/phpunit $PHPUNIT_FLAGS && php ./vendor/bin/behat
script:
- php ./vendor/bin/phpspec run --format=pretty
- php ./vendor/bin/phpunit $PHPUNIT_FLAGS
- php ./vendor/bin/behat

# Only send code coverage if it has been generated
after_success:
Expand Down
1 change: 1 addition & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ install:

test_script:
- cd c:\projects\asynctweetsbundle
- vendor/bin/phpspec run --format=pretty || SET X=!errorlevel!
- vendor/bin/phpunit --colors=never || SET X=!errorlevel!
- vendor/bin/behat || SET X=!errorlevel!
- exit %X%
1 change: 1 addition & 0 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ dependencies:
test:
override:
- mkdir -p $CIRCLE_TEST_REPORTS/phpunit
- php ./vendor/bin/phpspec run --format=pretty
- php ./vendor/bin/phpunit --log-junit $CIRCLE_TEST_REPORTS/phpunit/junit.xml
- php ./vendor/bin/behat
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
"behat/symfony2-extension": "^2.1",
"behat/mink": "^1.7",
"behat/mink-extension": "^2.2",
"behat/mink-browserkit-driver": "^1.3"
"behat/mink-browserkit-driver": "^1.3",
"phpspec/phpspec": "~3.4"
},
"autoload" : {
"psr-4" : {
Expand Down
58 changes: 58 additions & 0 deletions spec/AlexisLefebvre/Bundle/AsyncTweetsBundle/Entity/TweetSpec.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php

namespace spec\AlexisLefebvre\Bundle\AsyncTweetsBundle\Entity;

use AlexisLefebvre\Bundle\AsyncTweetsBundle\Entity\Tweet;
use PhpSpec\ObjectBehavior;

class TweetSpec extends ObjectBehavior
{
public function let(Tweet $tweet)
{
$this->beConstructedWith($tweet);

$fakeTweet = new \stdClass();
$fakeTweet->created_at = 'now';
$fakeTweet->text = 'Hello Twitter! #myfirstTweet';
$fakeTweet->retweet_count = 5;
$fakeTweet->favorite_count = 12;

$this->setValues($fakeTweet);
}

public function it_is_initializable()
{
$this->shouldHaveType(Tweet::class);
}

public function it_should_have_a_created_at_datetime()
{
$this->getCreatedAt()->shouldHaveType(new \DateTime);
}

public function it_should_have_the_title()
{
$this->getText()->shouldBeEqualTo('Hello Twitter! #myfirstTweet');
}

public function it_should_have_retweet_count()
{
$this->getRetweetCount()->shouldBeEqualTo(5);
}

public function it_should_have_favorite_count()
{
$this->getFavoriteCount()->shouldBeEqualTo(12);
}

public function it_should_not_be_in_timeline()
{
$this->shouldNotBeInTimeline();
}

public function it_should_not_allow_invalid_medias()
{
$this->shouldThrow('\TypeError')->during('addMedia', [null]);
$this->shouldThrow('\TypeError')->during('removeMedia', [null]);
}
}

0 comments on commit c14ad54

Please sign in to comment.