public function setUp() { $this->pdo = new \PDO("mysql:host=127.0.0.1;dbname=tests", 'root', ''); $this->pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); $this->pdo->exec('SET NAMES utf8'); /** * Table cars; SQLCommand */ $table = new CarTable($this->pdo); $this->carsSqlCommand = new SQLCommand($table->getTableName(), CarEntity::getColumns()); }
/** * @covers ::toArrayFromColumns */ public function testToArrayFromColumns() { $carEntity = new CarEntity('Ford', 'Model T', 20, 'TWO', new \DateTime('1908-10-01')); $reflector = new \ReflectionClass($carEntity); $method = $reflector->getMethod('toArrayFromColumns'); $method->setAccessible(true); $expected = [':id' => $carEntity->get('id'), ':make' => 'Ford', ':model' => 'Model T', ':horsepower' => 20, ':doors' => 'TWO', ':released' => '1908-10-01', ':modified' => (new \DateTime())->format('Y-m-d H:i:s'), ':created' => (new \DateTime())->format('Y-m-d H:i:s')]; $this->assertSame($expected, $method->invoke($carEntity, $carEntity::getColumns())); }