Tests/Functional/Import/SyncExecuteCommandTest.php
/**
     * Check if sync actually changes anything.
     */
Check if sync actually changes anything.
Check if sync actually changes anything .
public function testExecute()
    {
        $manager = $this->getManager();
        $application = new Application(static::$kernel);
        $application->add(new ImportFullCommand());
        $command = $application->find('ongr:import:full');
        $commandTester = new CommandTester($command);
        $commandTester->execute(['command' => $command->getName()]);
        $this->setLastSync(new DateTime('now'), BinlogParser::START_TYPE_DATE);
        $this->importData('Import/diffmaker.sql');
        $application = new Application(static::$kernel);
        $application->add(new SyncProvideCommand());
        $command = $application->find('ongr:sync:provide');
        $commandTester = new CommandTester($command);
        $commandTester->execute(
            [
                'command' => $command->getName(),
                'target' => 'default',
            ]
        );
        $application = new Application(static::$kernel);
        $application->add(new SyncExecuteCommand());
        $command = $application->find('ongr:sync:execute');
        $commandTester = new CommandTester($command);
        $commandTester->execute(
            [
                'command' => $command->getName(),
                'target' => 'default',
            ]
        );
        $actualDocuments = [];
        $manager->refresh();
        foreach ($this->repositories as $key) {
            $repository = $manager->getRepository($key);
            foreach ($repository->execute(new Search(), Repository::RESULTS_ARRAY) as $item) {
                $actualDocuments[$key][] = $item;
            }
        }
        foreach ($this->repositories as $key) {
            sort($actualDocuments[$key]);
            sort($this->expectedDocuments[$key]);
        }
        $this->assertEquals($this->expectedDocuments, $actualDocuments);
    }
public function testExecute ( ) { $ manager = $ this -> getManager ( ) ; $ application = new Application ( static :: $ kernel ) ; $ application -> add ( new ImportFullCommand ( ) ) ; $ command = $ application -> find ( 'ongr:import:full' ) ; $ commandTester = new CommandTester ( $ command ) ; $ commandTester -> execute ( [ 'command' => $ command -> getName ( ) ] ) ; $ this -> setLastSync ( new DateTime ( 'now' ) , BinlogParser :: START_TYPE_DATE ) ; $ this -> importData ( 'Import/diffmaker.sql' ) ; $ application = new Application ( static :: $ kernel ) ; $ application -> add ( new SyncProvideCommand ( ) ) ; $ command = $ application -> find ( 'ongr:sync:provide' ) ; $ commandTester = new CommandTester ( $ command ) ; $ commandTester -> execute ( [ 'command' => $ command -> getName ( ) , 'target' => 'default' , ] ) ; $ application = new Application ( static :: $ kernel ) ; $ application -> add ( new SyncExecuteCommand ( ) ) ; $ command = $ application -> find ( 'ongr:sync:execute' ) ; $ commandTester = new CommandTester ( $ command ) ; $ commandTester -> execute ( [ 'command' => $ command -> getName ( ) , 'target' => 'default' , ] ) ; $ actualDocuments = [ ] ; $ manager -> refresh ( ) ; foreach ( $ this -> repositories as $ key ) { $ repository = $ manager -> getRepository ( $ key ) ; foreach ( $ repository -> execute ( new Search ( ) , Repository :: RESULTS_ARRAY ) as $ item ) { $ actualDocuments [ $ key ] [ ] = $ item ; } } foreach ( $ this -> repositories as $ key ) { sort ( $ actualDocuments [ $ key ] ) ; sort ( $ this -> expectedDocuments [ $ key ] ) ; } $ this -> assertEquals ( $ this -> expectedDocuments , $ actualDocuments ) ; }
Check if sync actually changes anything.
Check if sync actually changes anything .
// Set last sync date to now. // Check results.