tests/unit/Subjects/MoveFilesSubjectTest.php
/**
     * The the import() method with a matching file and an existing source directory.
     *
     * @return void
     */
The the import() method with a matching file and an existing source directory.
@return void
The the import () method with a matching file and an existing source directory . @return void
public function testImportWithMatchingFileAndExistingSourceDir()
    {
        $filename = sprintf('%s/product-import_20170711-110012_01.csv', $targetDir = 'var/importexport');
        $this->moveFilesSubject
             ->getConfiguration()
             ->expects($this->once())
             ->method('getTargetDir')
             ->willReturn($targetDir = 'var/importexport');
        $this->moveFilesSubject
             ->expects($this->once())
             ->method('isDir')
             ->with($newSourceDir = sprintf('%s/%s', $targetDir, $this->serial))
             ->willReturn(true);
        $this->moveFilesSubject
             ->expects($this->once())
             ->method('rename')
             ->with($filename, sprintf('%s/%s', $newSourceDir, basename($filename)))
             ->willReturn(true);
        $this->moveFilesSubject->setSerial($this->serial);
        $this->assertNull($this->moveFilesSubject->import($this->serial, $filename));
    }
public function testImportWithMatchingFileAndExistingSourceDir ( ) { $ filename = sprintf ( '%s/product-import_20170711-110012_01.csv' , $ targetDir = 'var/importexport' ) ; $ this -> moveFilesSubject -> getConfiguration ( ) -> expects ( $ this -> once ( ) ) -> method ( 'getTargetDir' ) -> willReturn ( $ targetDir = 'var/importexport' ) ; $ this -> moveFilesSubject -> expects ( $ this -> once ( ) ) -> method ( 'isDir' ) -> with ( $ newSourceDir = sprintf ( '%s/%s' , $ targetDir , $ this -> serial ) ) -> willReturn ( true ) ; $ this -> moveFilesSubject -> expects ( $ this -> once ( ) ) -> method ( 'rename' ) -> with ( $ filename , sprintf ( '%s/%s' , $ newSourceDir , basename ( $ filename ) ) ) -> willReturn ( true ) ; $ this -> moveFilesSubject -> setSerial ( $ this -> serial ) ; $ this -> assertNull ( $ this -> moveFilesSubject -> import ( $ this -> serial , $ filename ) ) ; }
The the import() method with a matching file and an existing source directory.
The the import () method with a matching file and an existing source directory .
// initialize the filename // mock the method returning the new source directory // mock the isDir() method // mock the rename() method // set the serial // invoke the import method