Chapters
28 Chapters
|
2:54:11
|
Login to bookmark this video
-
Course Code
Subscribe to download the code!
Subscribe to download the code!
-
This Video
Subscribe to download the video!
Subscribe to download the video!
-
Subtitles
Subscribe to download the subtitles!
Subscribe to download the subtitles!
-
Course Script
Subscribe to download the script!
Subscribe to download the script!
02.
Buzzwords! Specification & Examples
Scroll down to the script below, click on any sentence (including terminal blocks) to jump to that spot in the video!
Subscribe to jump to this part in the video!
12 Comments
Hi!
When I run the test, phpspec throws an error instead of suggesting me to create the non-exists method on real class.
// my test method
function it_shoult_return_5()
{
$this->getLength()->shouldBe(5);
}
// error
App/Models/Student
16 - it shoult return 5
exception [err:Error("Call to a member function connection() on null")] has been thrown.
Hey Emakina F.!
Ah! I don't like that error at all! Do you have a
connection()method anywhere in your code? I thought at first that this error might be some low-level error coming from phpspec. But, if I search the entire vendor/ directory of this project, I don't see any method called "connection()". So I'm wondering if this might be referring to something in your code?Cheers!
Thanks weaverryan for response.
I don't have that method in my code and I don't have any idea about that. When I started with pure PHP & PHPSpec it works well, but when I tried to use PHPSpec on Slim Framework entities it failed. I thought it might be Slim related.
Hey Emakina F. !
Hmm. Indeed. Doing some quick googling, it looks like it could be from Eloquent - are you using Eloquent with Slim by chance? I don't know the fix exactly, but if you search for "Call to a member function connection() on null slim" or "Call to a member function connection() on null eloquent" you'll see references. What's odd is that everything is mocked in PHPSpec... so it "shouldn't" (with big quotes) matter what ORM or framework you're using. But... it seems something is going on here related (I think) to Eloquent.
Cheers!
Hi weaverryan
Yes, I am using Eloquent with Slim in that application, thanks a lot for better googling then me :D I will take care of it, have a nice day :)
Hi!
I have problem when I running command, on my win10
php vendor/bin/phpspec describe -h
Output is:
dir=$(cd "${0%[/\\]*}" > /dev/null; cd "../phpspec/phpspec/bin" && pwd)
if [ -d /proc/cygdrive ] && [[ $(which php) == $(readlink -n /proc/cygdrive)/* ]]; then
# We are in Cgywin using Windows php, so the path must be translated
dir=$(cygpath -m "$dir");
fi
"${dir}/phpspec" "$@"
How can I resolve this problem?
Thank you!
Maybe i can offer a solution that is a bit more... well "handy". In my case this is a symfony-project.
Go to your Project-Root and find the "bin" folder. Make a new file named phpspec and paste this chunk of code right in:
`#!/usr/bin/env php
< ? php // <-- please note, that i had to fill in whitespaces here, because disqus doesen't like my post otherwise
if (!file_exists(dirname(DIR).'/vendor/phpspec/phpspec/bin/phpspec')) {
}
require dirname(DIR).'/vendor/phpspec/phpspec/bin/phpspec';`
Now you should be able to call phpspec simply by typing the command "php bin/phpspec run".
Aaaand it feels more "natural" if you work with "php bin/console" and "php bin/phpunit" too :D
Maybe this makes things more beautiful =)
I like it! Thanks for sharing :)
Ok, I have already resolved the problem. Instead of using
php vendor/bin/phpspec describe -h
I use:
php vendor/phpspec/phpspec/bin/phpspec
Hey MichalWilczynski!
Yes! Nice find! OR, use try this syntax:
(or you may need to change the slashes
\.vendor\bin\phpspec). The phpspec is a "bat" file for Window, so instead of executing it via php, you're supposed to execute it directly. But, it's just kinda tricky. You'll notice that in the script we always use the./vendor/bin/phpspecversion of the command - it's a bit more portable across operating systems.Cheers!
Great!
Your solution also works! I changed slashes to backslahses and command
.\.vendor\bin\phpspec
works like a harm :D
Hey Nicoweb!
Why do you think so? :) We're working on phpspec tutorial right now, that's why it's been releasing these days. The previous one: "Symfony 4 Forms: Build, Render & Conquer!" - was completely released recently :)
P.S. But sure, releasing a few tutorials at the same time is our goal :)
Cheers!
"Houston: no signs of life"
Start the conversation!