Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Dec 14, 2024. It is now read-only.

Commit c14ad54

Browse files
Add PHPSpec
1 parent 8d45bb0 commit c14ad54

6 files changed

Lines changed: 68 additions & 2 deletions

File tree

.scrutinizer.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ build:
2727
idle_timeout: 900
2828
tests:
2929
override:
30+
-
31+
command: './vendor/bin/phpspec run --format=pretty'
3032
-
3133
command: './vendor/bin/phpunit --coverage-clover=coverage-clover'
3234
coverage:

.travis.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,10 @@ install:
3737
- composer require --dev symfony/symfony:${SYMFONY_VERSION} $DEPENDENCY --no-update
3838
- composer install --no-interaction --profile --no-progress
3939

40-
script: php ./vendor/bin/phpunit $PHPUNIT_FLAGS && php ./vendor/bin/behat
40+
script:
41+
- php ./vendor/bin/phpspec run --format=pretty
42+
- php ./vendor/bin/phpunit $PHPUNIT_FLAGS
43+
- php ./vendor/bin/behat
4144

4245
# Only send code coverage if it has been generated
4346
after_success:

appveyor.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ install:
4343

4444
test_script:
4545
- cd c:\projects\asynctweetsbundle
46+
- vendor/bin/phpspec run --format=pretty || SET X=!errorlevel!
4647
- vendor/bin/phpunit --colors=never || SET X=!errorlevel!
4748
- vendor/bin/behat || SET X=!errorlevel!
4849
- exit %X%

circle.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@ dependencies:
1313
test:
1414
override:
1515
- mkdir -p $CIRCLE_TEST_REPORTS/phpunit
16+
- php ./vendor/bin/phpspec run --format=pretty
1617
- php ./vendor/bin/phpunit --log-junit $CIRCLE_TEST_REPORTS/phpunit/junit.xml
1718
- php ./vendor/bin/behat

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@
2828
"behat/symfony2-extension": "^2.1",
2929
"behat/mink": "^1.7",
3030
"behat/mink-extension": "^2.2",
31-
"behat/mink-browserkit-driver": "^1.3"
31+
"behat/mink-browserkit-driver": "^1.3",
32+
"phpspec/phpspec": "~3.4"
3233
},
3334
"autoload" : {
3435
"psr-4" : {
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?php
2+
3+
namespace spec\AlexisLefebvre\Bundle\AsyncTweetsBundle\Entity;
4+
5+
use AlexisLefebvre\Bundle\AsyncTweetsBundle\Entity\Tweet;
6+
use PhpSpec\ObjectBehavior;
7+
8+
class TweetSpec extends ObjectBehavior
9+
{
10+
public function let(Tweet $tweet)
11+
{
12+
$this->beConstructedWith($tweet);
13+
14+
$fakeTweet = new \stdClass();
15+
$fakeTweet->created_at = 'now';
16+
$fakeTweet->text = 'Hello Twitter! #myfirstTweet';
17+
$fakeTweet->retweet_count = 5;
18+
$fakeTweet->favorite_count = 12;
19+
20+
$this->setValues($fakeTweet);
21+
}
22+
23+
public function it_is_initializable()
24+
{
25+
$this->shouldHaveType(Tweet::class);
26+
}
27+
28+
public function it_should_have_a_created_at_datetime()
29+
{
30+
$this->getCreatedAt()->shouldHaveType(new \DateTime);
31+
}
32+
33+
public function it_should_have_the_title()
34+
{
35+
$this->getText()->shouldBeEqualTo('Hello Twitter! #myfirstTweet');
36+
}
37+
38+
public function it_should_have_retweet_count()
39+
{
40+
$this->getRetweetCount()->shouldBeEqualTo(5);
41+
}
42+
43+
public function it_should_have_favorite_count()
44+
{
45+
$this->getFavoriteCount()->shouldBeEqualTo(12);
46+
}
47+
48+
public function it_should_not_be_in_timeline()
49+
{
50+
$this->shouldNotBeInTimeline();
51+
}
52+
53+
public function it_should_not_allow_invalid_medias()
54+
{
55+
$this->shouldThrow('\TypeError')->during('addMedia', [null]);
56+
$this->shouldThrow('\TypeError')->during('removeMedia', [null]);
57+
}
58+
}

0 commit comments

Comments
 (0)