コード例 #1
0
ファイル: EntityTest.php プロジェクト: Anyqax/Phabric
 public function testInsertFromTableWithNamedDefaultDataTransformation()
 {
     $tableData = array(array('Name' => 'PHPNW', 'Date' => '2011-10-08 09:00:00', 'The Venue' => 'Ramada Hotel', 'Desc' => 'A Great Conf!'));
     $tableNode = m::mock('Behat\\Gherkin\\Node\\TableNode');
     $tableNode->shouldReceive('getHash')->withNoArgs()->andReturn($tableData)->once();
     $expectedInsert = array('name' => 'PHPNW', 'DateTime' => '2011-10-08 09:00:00', 'the_venue' => 'Ramada Hotel', 'Description' => 'A Great Conf!');
     $this->mockedConnection->shouldReceive('insert')->with('\\Phabric\\Entity', $expectedInsert)->once();
     $retFn = function ($name) {
         // oh no, it's a snake...
         return strtolower(str_replace(' ', '_', $name));
     };
     $this->mockedBus->shouldReceive('getDataTransformation')->with('SNAKE_CASE')->twice()->andReturn($retFn);
     $this->object->setDefaultNameTransformation('SNAKE_CASE');
     $this->object->setNameTransformations(array('Date' => 'DateTime', 'Desc' => 'Description'));
     $this->object->insertFromTable($tableNode);
 }