Final subscriber with ORM.
This commit is contained in:
@@ -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();
|
||||
|
@@ -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);
|
||||
}
|
||||
|
@@ -1,19 +1,56 @@
|
||||
<?php
|
||||
use \UnitTester;
|
||||
use \MailPoet\Models\Subscriber;
|
||||
|
||||
class SubscriberCest {
|
||||
|
||||
public function _before() {
|
||||
$this->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();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user