diff --git a/RoboFile.php b/RoboFile.php index 68e5988f09..ec7c50bd7e 100644 --- a/RoboFile.php +++ b/RoboFile.php @@ -72,6 +72,12 @@ class RoboFile extends \Robo\Tasks { $this->_exec('vendor/bin/codecept run'); } + function testDebug() { + $this->_exec('vendor/bin/codecept build'); + $this->loadEnv(); + $this->_exec('vendor/bin/codecept run unit --debug'); + } + protected function loadEnv() { $dotenv = new Dotenv\Dotenv(__DIR__); $dotenv->load(); diff --git a/lib/config/env.php b/lib/config/env.php index 879d8ea030..6124b35f56 100644 --- a/lib/config/env.php +++ b/lib/config/env.php @@ -28,10 +28,10 @@ class Env { public static function dbSourceName() { $source_name = array( 'mysql:host=', - Env::$db_host, + DB_HOST, ';', 'dbname=', - Env::$db_name + DB_NAME ); return implode('', $source_name); } diff --git a/tests/unit/SubscriberCest.php b/tests/unit/SubscriberCest.php index 256cf5dead..fe229449fc 100644 --- a/tests/unit/SubscriberCest.php +++ b/tests/unit/SubscriberCest.php @@ -1,19 +1,56 @@ subscriber = \Model::factory('Subscriber')->create(); - $this->subscriber->first_name = 'John'; - $this->subscriber->last_name = 'Mailer'; - $this->subscriber->email = 'john@mailpoet.com'; + function _before() { + $this->data = array( + 'first_name' => 'John', + 'last_name' => 'Mailer', + 'email' => 'john@mailpoet.com' + ); + + $this->subscriber = Subscriber::create(); + + $this + ->subscriber + ->first_name = $this->data['first_name']; + + $this + ->subscriber + ->last_name = $this->data['last_name']; + + $this->subscriber->email = $this->data['email']; + $this->subscriber->save(); + $this->id = $this->subscriber->id; } - public function itCanBeCreated() { + function itCanBeCreated() { + $subscriber = Subscriber::where('first_name', $this->data['first_name'])->findOne(); + expect($subscriber->id)->notNull(); } - public function _after() { + function itHasAFirstName() { + $subscriber = Subscriber::findOne($this->id); + expect($subscriber->first_name) + ->equals($this->data['first_name']); + } + + function itHasALastName() { + $subscriber = Subscriber::findOne($this->id); + expect($subscriber->last_name) + ->equals($this->data['last_name']); + } + + function itHasAnEmail() { + $subscriber = Subscriber::findOne($this->id); + expect($subscriber->email) + ->equals($this->data['email']); + } + + function _after() { + Subscriber::findOne($this->id)->delete(); } }