asu-ke-web-services / search-api

Search API for documents, data, research, people, etc
MIT License
2 stars 1 forks source link

SearchEngineSpec Test Question #26

Closed ESmith92 closed 9 years ago

ESmith92 commented 9 years ago

How does $this know to be an instance of the SearchEngine? does the test case of $this->shouldHaveType( 'SearchApi\SearchEngine' ); assign $this to a SearchEngine instance?

ESmith92 commented 9 years ago

Also where do the SearchEngineSpec functions get called when the test is run? aka how do I add my own spec test?

idmontie commented 9 years ago

We use PhpSpec which will automatically do magic for you. When following the PhpSpec convention, PhpSpec will automatically run all of your tests (you don't have to "add" your spec test to any sort of list of test).

It will also automagically make the Test object (IE, SearchEngineTest or w/e its called) an instance of SearchEngine.

It's magic! :zap:

ESmith92 commented 9 years ago

alright, but how does the $this in the test end up as an instance of SearchEngine? so that $this->handle_request calls SearchEngine's handle_request function?

ESmith92 commented 9 years ago

One more question: it will test my branch as well or do I need to put it in my local develop branch to test it?

idmontie commented 9 years ago

I recommend reading this: http://www.phpspec.net/en/latest/manual/getting-started.html

Specifically this line might clear up some confusion:

phpspec searches for these methods in your specification to run.

So if you are writing SearchItemSpec, then it will look for handle if we call $this->handle in SearchItem. It's called meta programming iirc.


For your other question, TravisCI will run PhpSpec for anything that you push to Github. You can run PhpSpec locally on your machine as well.

ESmith92 commented 9 years ago

k, thank you