@@ -203,7 +203,7 @@ |
||
| 203 | 203 | /** |
| 204 | 204 | * Save the model data to the database. |
| 205 | 205 | * |
| 206 | - * @return bool |
|
| 206 | + * @return integer |
|
| 207 | 207 | */ |
| 208 | 208 | public function save() |
| 209 | 209 | { |
@@ -17,22 +17,22 @@ discard block |
||
| 17 | 17 | */ |
| 18 | 18 | protected $databaseConnection; |
| 19 | 19 | |
| 20 | - /** |
|
| 21 | - * The id of the model. |
|
| 22 | - * |
|
| 23 | - * @property string $id |
|
| 24 | - */ |
|
| 25 | - |
|
| 26 | - /** |
|
| 27 | - * Create a model instance. |
|
| 28 | - */ |
|
| 29 | - public function __construct(DatabaseConnectionInterface $databaseConnection = null) |
|
| 30 | - { |
|
| 31 | - if ($databaseConnection == null) { |
|
| 32 | - $this->databaseConnection = DatabaseConnection::getInstance()->databaseConnection; |
|
| 33 | - } |
|
| 34 | - $this->databaseConnection = $databaseConnection; |
|
| 35 | - } |
|
| 20 | + /** |
|
| 21 | + * The id of the model. |
|
| 22 | + * |
|
| 23 | + * @property string $id |
|
| 24 | + */ |
|
| 25 | + |
|
| 26 | + /** |
|
| 27 | + * Create a model instance. |
|
| 28 | + */ |
|
| 29 | + public function __construct(DatabaseConnectionInterface $databaseConnection = null) |
|
| 30 | + { |
|
| 31 | + if ($databaseConnection == null) { |
|
| 32 | + $this->databaseConnection = DatabaseConnection::getInstance()->databaseConnection; |
|
| 33 | + } |
|
| 34 | + $this->databaseConnection = $databaseConnection; |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | 37 | /** |
| 38 | 38 | * Sets into $properties the $key => $value pairs. |
@@ -55,23 +55,23 @@ discard block |
||
| 55 | 55 | return $this->properties[$key]; |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | - /** |
|
| 59 | - * Get all the model properties. |
|
| 60 | - * |
|
| 61 | - * @return array |
|
| 62 | - */ |
|
| 63 | - public function getProperties() |
|
| 64 | - { |
|
| 65 | - return $this->properties; |
|
| 66 | - } |
|
| 67 | - |
|
| 68 | - /** |
|
| 69 | - * Set model properties. |
|
| 70 | - */ |
|
| 71 | - public function setProperties(array $properties) |
|
| 72 | - { |
|
| 73 | - $this->properties = $properties; |
|
| 74 | - } |
|
| 58 | + /** |
|
| 59 | + * Get all the model properties. |
|
| 60 | + * |
|
| 61 | + * @return array |
|
| 62 | + */ |
|
| 63 | + public function getProperties() |
|
| 64 | + { |
|
| 65 | + return $this->properties; |
|
| 66 | + } |
|
| 67 | + |
|
| 68 | + /** |
|
| 69 | + * Set model properties. |
|
| 70 | + */ |
|
| 71 | + public function setProperties(array $properties) |
|
| 72 | + { |
|
| 73 | + $this->properties = $properties; |
|
| 74 | + } |
|
| 75 | 75 | |
| 76 | 76 | /** |
| 77 | 77 | * Gets the name of the child class with a 's'. |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | m::mock('Pyjac\ORM\DatabaseConnectionStringFactoryInterface'); |
| 22 | 22 | |
| 23 | 23 | $databaseConnectionStringFactory->shouldReceive('createDatabaseSourceString') |
| 24 | - ->with(['DRIVER' => 'sqlite', 'HOSTNAME' => '127.0.0.1', 'USERNAME' => '', 'PASSWORD' => '', 'DBNAME' => 'potatoORM', 'PORT' => '54320'])->once()->andReturn('sqlite::memory:'); |
|
| 24 | + ->with(['DRIVER' => 'sqlite', 'HOSTNAME' => '127.0.0.1', 'USERNAME' => '', 'PASSWORD' => '', 'DBNAME' => 'potatoORM', 'PORT' => '54320'])->once()->andReturn('sqlite::memory:'); |
|
| 25 | 25 | |
| 26 | 26 | $this->databaseConnection = m::mock('Pyjac\ORM\DatabaseConnection'); |
| 27 | 27 | |
@@ -36,8 +36,8 @@ discard block |
||
| 36 | 36 | { |
| 37 | 37 | $this->databaseConnection->shouldReceive('createConnection')->with('sqlite::memory:')->once()->andReturn(''); |
| 38 | 38 | $this->model->expects($this->any()) |
| 39 | - ->method('getTableName') |
|
| 40 | - ->will($this->returnValue(strtolower(get_class($this->model).'s'))); |
|
| 39 | + ->method('getTableName') |
|
| 40 | + ->will($this->returnValue(strtolower(get_class($this->model).'s'))); |
|
| 41 | 41 | |
| 42 | 42 | $this->assertEquals($this->model->getTableName(), strtolower(get_class($this->model).'s')); |
| 43 | 43 | } |
@@ -160,16 +160,16 @@ |
||
| 160 | 160 | ]); |
| 161 | 161 | } |
| 162 | 162 | |
| 163 | - /** |
|
| 164 | - * Load needed configuration values from the .env file using Dotenv. |
|
| 165 | - * |
|
| 166 | - * @return void |
|
| 167 | - */ |
|
| 168 | - public function loadEnv() |
|
| 169 | - { |
|
| 170 | - if (!getenv('APP_ENV')) { |
|
| 171 | - $dotenv = new \Dotenv\Dotenv(__DIR__.'/../../../'); |
|
| 172 | - $dotenv->overload(); |
|
| 173 | - } |
|
| 174 | - } |
|
| 163 | + /** |
|
| 164 | + * Load needed configuration values from the .env file using Dotenv. |
|
| 165 | + * |
|
| 166 | + * @return void |
|
| 167 | + */ |
|
| 168 | + public function loadEnv() |
|
| 169 | + { |
|
| 170 | + if (!getenv('APP_ENV')) { |
|
| 171 | + $dotenv = new \Dotenv\Dotenv(__DIR__.'/../../../'); |
|
| 172 | + $dotenv->overload(); |
|
| 173 | + } |
|
| 174 | + } |
|
| 175 | 175 | } |
@@ -16,11 +16,11 @@ discard block |
||
| 16 | 16 | */ |
| 17 | 17 | protected $databaseConnectionStringFactory; |
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * root directory |
|
| 21 | - * |
|
| 22 | - * @type vfsStreamDirectory |
|
| 23 | - */ |
|
| 19 | + /** |
|
| 20 | + * root directory |
|
| 21 | + * |
|
| 22 | + * @type vfsStreamDirectory |
|
| 23 | + */ |
|
| 24 | 24 | protected $root; |
| 25 | 25 | |
| 26 | 26 | public function setUp() |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | $this->databaseConnectionStringFactory = |
| 29 | 29 | m::mock('Pyjac\ORM\DatabaseConnectionStringFactoryInterface'); |
| 30 | 30 | $this->databaseConnectionStringFactory->shouldReceive('createDatabaseSourceString') |
| 31 | - ->with(['DRIVER' => 'sqlite', 'HOSTNAME' => '127.0.0.1', 'USERNAME' => '', 'PASSWORD' => '', 'DBNAME' => 'potatoORM', 'PORT' => '54320'])->once()->andReturn('sqlite::memory:'); |
|
| 31 | + ->with(['DRIVER' => 'sqlite', 'HOSTNAME' => '127.0.0.1', 'USERNAME' => '', 'PASSWORD' => '', 'DBNAME' => 'potatoORM', 'PORT' => '54320'])->once()->andReturn('sqlite::memory:'); |
|
| 32 | 32 | |
| 33 | 33 | $this->databaseConnection = new DatabaseConnection($this->databaseConnectionStringFactory); |
| 34 | 34 | } |