public function test_process_upsertEventsGetCalled()
 {
     $mockPdoFacade = \Mockery::mock('\\TestDbAcle\\Db\\Mysql\\Pdo\\PdoFacade');
     $dataTree = new \TestDbAcle\Psv\PsvTree();
     $dataTree->addTable(new \TestDbAcle\Psv\Table\Table('user', array(array("user_id" => "10", "first_name" => "john", "last_name" => "miller"), array("user_id" => "20", "first_name" => "stu", "last_name" => "Smith"))));
     $self = $this;
     // we need to pass this in for PHP version<5.4
     $checkUpserterClosure = function ($upserter) use($self) {
         $self->assertTrue($upserter instanceof \TestDbAcle\Db\DataInserter\Sql\InsertBuilder);
         $self->assertEquals('user', $upserter->getTableName());
         return true;
     };
     $testListener1 = \Mockery::mock('\\TestDbAcle\\Db\\DataInserter\\UpsertListenerInterface');
     $testListener2 = \Mockery::mock('\\TestDbAcle\\Db\\DataInserter\\UpsertListenerInterface');
     $mockPdoFacade->shouldReceive('clearTable')->once()->with('user')->ordered();
     $mockPdoFacade->shouldReceive('executeSql')->once()->with("INSERT INTO `user` ( `user_id`, `first_name`, `last_name` ) VALUES ( '10', 'john', 'miller' )")->ordered();
     $testListener1->shouldReceive('afterUpsert')->once()->with(\Mockery::on($checkUpserterClosure));
     $testListener2->shouldReceive('afterUpsert')->once()->with(\Mockery::on($checkUpserterClosure));
     $mockPdoFacade->shouldReceive('executeSql')->once()->with("INSERT INTO `user` ( `user_id`, `first_name`, `last_name` ) VALUES ( '20', 'stu', 'Smith' )")->ordered();
     $testListener1->shouldReceive('afterUpsert')->once()->with(\Mockery::on($checkUpserterClosure));
     $testListener2->shouldReceive('afterUpsert')->once()->with(\Mockery::on($checkUpserterClosure));
     $dataInserter = new \TestDbAcle\Db\DataInserter\DataInserter($mockPdoFacade, new \TestDbAcle\Db\DataInserter\Factory\UpsertBuilderFactory($mockPdoFacade));
     $dataInserter->addUpsertListener($testListener1);
     $dataInserter->addUpsertListener($testListener2);
     $dataInserter->process($dataTree);
 }
 public function getFactoriesMysql()
 {
     return array('dataInserter' => function (\TestDbAcle\ServiceLocator $serviceLocator) {
         $dataInserter = new \TestDbAcle\Db\DataInserter\DataInserter($serviceLocator->get('pdoFacade'), $serviceLocator->get('upsertBuilderFactory'));
         $dataInserter->addUpsertListener(new \TestDbAcle\Db\DataInserter\Listeners\MysqlZeroPKListener($serviceLocator->get('pdoFacade'), $serviceLocator->get('tableList')));
         return $dataInserter;
     }, 'pdoFacade' => function (\TestDbAcle\ServiceLocator $serviceLocator) {
         $pdoFacade = new \TestDbAcle\Db\Mysql\Pdo\PdoFacade($serviceLocator->get('pdo'));
         $pdoFacade->disableForeignKeyChecks();
         $pdoFacade->enableExceptions();
         return $pdoFacade;
     }, 'tableFactory' => function (\TestDbAcle\ServiceLocator $serviceLocator) {
         return new \TestDbAcle\Db\Mysql\TableFactory($serviceLocator->get('pdoFacade'));
     });
 }