Last active
September 6, 2016 14:17
-
-
Save rafi/7823094 to your computer and use it in GitHub Desktop.
phpspec+kohana 3.3 integration
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // src/kohana/classes/Sortex/KohanaBundle/PhpSpec/Bridge.php | |
| namespace Sortex\KohanaBundle\PhpSpec; | |
| use PhpSpec\Extension; | |
| use PhpSpec\ServiceContainer; | |
| /** | |
| * PHPSpec Kohana extension | |
| * See /phpspec.yml | |
| */ | |
| class Bridge implements Extension\ExtensionInterface { | |
| /** | |
| * Loading a slim bootstrap for | |
| * @param ServiceContainer $container | |
| */ | |
| public function load(ServiceContainer $container) | |
| { | |
| define('APP_NAME', 'name'); | |
| define('APP_VERSION', '0.4.x'); | |
| define('APP_REVISION', ''); | |
| define('API_VERSION', 'v1'); | |
| define('EXT', '.php'); | |
| // Forcing 'testing' environment | |
| define('ENV_NAME', 'testing'); | |
| putenv('KOHANA_ENV=testing'); | |
| $root = '../../../../../../'; | |
| define('DOCROOT', realpath(dirname(__FILE__)."/$root/public/").DIRECTORY_SEPARATOR); | |
| $application = DOCROOT.'../apps/'.APP_NAME; | |
| $modules = DOCROOT.'../kohana/modules'; | |
| $system = DOCROOT.'../kohana/system'; | |
| $source_code = DOCROOT.'../src'; | |
| $widgets = DOCROOT.'../widgets'; | |
| $themes = DOCROOT.'../themes'; | |
| error_reporting(E_ALL | E_STRICT); | |
| define('APPPATH', realpath($application).DIRECTORY_SEPARATOR); | |
| define('MODPATH', realpath($modules).DIRECTORY_SEPARATOR); | |
| define('SYSPATH', realpath($system).DIRECTORY_SEPARATOR); | |
| define('SRCPATH', realpath($source_code).DIRECTORY_SEPARATOR); | |
| define('WGTPATH', realpath($widgets).DIRECTORY_SEPARATOR); | |
| define('THMPATH', realpath($themes).DIRECTORY_SEPARATOR); | |
| unset($application, $modules, $system, $source_code, $root, $themes, $widgets); | |
| require DOCROOT.'bootstrap'.EXT; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "require-dev": { | |
| "phpspec/phpspec": "2.0.*@dev" | |
| }, | |
| "config": { | |
| "bin-dir": "bin" | |
| }, | |
| "autoload": { | |
| "psr-0": { | |
| "": "src/core/classes", | |
| "Sortex\\KohanaBundle": "src/kohana/classes", | |
| "Sortex\\ResourceBundle": "src/resource/classes", | |
| "Sortex\\UserBundle": "src/user/classes", | |
| "Sortex\\WidgetBundle": "src/widget/classes" | |
| } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // src/core/classes/Sortex/CoreBundle/Context/User/Create.php | |
| namespace Sortex\CoreBundle\Context\User; | |
| use Sortex\UserBundle\Repository; | |
| use Sortex\UserBundle\Model; | |
| use Bonafide; | |
| use Validation_Exception; | |
| use Auth, Arr; | |
| /** | |
| * User's creation use-case | |
| */ | |
| class Create { | |
| ... | |
| } | |
| // --------------------------------------------------------------- | |
| // src/core/spec/Sortex/CoreBundle/Context/User/CreateSpec.php | |
| namespace spec\Sortex\CoreBundle\Context\User; | |
| use Sortex\UserBundle\Repository; | |
| use Sortex\UserBundle\Model; | |
| use Bonafide; | |
| use Validation; | |
| use PhpSpec\ObjectBehavior; | |
| use Prophecy\Argument; | |
| /** | |
| * User's creation specs | |
| */ | |
| class CreateSpec extends ObjectBehavior { | |
| ... | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // apps/name/classes/Controller/User.php | |
| namespace Controller; | |
| class User { | |
| ... | |
| } | |
| // --------------------------------------------------------------- | |
| // apps/name/spec/Controller/UserSpec.php | |
| namespace spec\Controller; | |
| use PhpSpec\ObjectBehavior; | |
| use Prophecy\Argument; | |
| /** | |
| * User's controller specs | |
| */ | |
| class UserSpec extends ObjectBehavior { | |
| ... | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| suites: | |
| core_bundle: | |
| namespace: Sortex\CoreBundle | |
| src_path: src/core/classes | |
| spec_path: src/core | |
| resource_bundle: | |
| namespace: Sortex\ResourceBundle | |
| src_path: src/resource/classes | |
| spec_path: src/resource | |
| user_bundle: | |
| namespace: Sortex\UserBundle | |
| src_path: src/user/classes | |
| spec_path: src/user | |
| widget_bundle: | |
| namespace: Sortex\WidgetBundle | |
| src_path: src/widget/classes | |
| spec_path: src/widget | |
| formatter.name: pretty | |
| extensions: | |
| - Sortex\KohanaBundle\PhpSpec\Bridge |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment