11<?php
22namespace phpbu \App \Backup \File ;
33
4+ use DateTimeImmutable ;
5+ use Exception ;
46use SebastianFeldmann ;
57use PHPUnit \Framework \TestCase ;
8+ use SebastianFeldmann \Ftp \Client ;
9+ use SebastianFeldmann \Ftp \File ;
610
711/**
812 * FtpTest
@@ -23,24 +27,24 @@ class FtpTest extends TestCase
2327 */
2428 public function testFile ()
2529 {
26- $ ftpClient = $ this ->createMock (\ SebastianFeldmann \ Ftp \ Client::class);
30+ $ ftpClient = $ this ->createMock (Client::class);
2731 $ ftpClient ->expects ($ this ->once ())->method ('chHome ' );
2832 $ ftpClient ->expects ($ this ->once ())
2933 ->method ('__call ' );
3034
3135 $ remotePath = 'backups ' ;
32- $ ftpFile = $ this ->createMock (\ SebastianFeldmann \ Ftp \ File::class);
36+ $ ftpFile = $ this ->createMock (File::class);
3337 $ ftpFile ->expects ($ this ->exactly (2 ))->method ('getFilename ' )->willReturn ('foo.txt ' );
3438 $ ftpFile ->expects ($ this ->once ())->method ('getSize ' )->willReturn (102102 );
3539 $ ftpFile ->expects ($ this ->once ())
3640 ->method ('getLastModifyDate ' )
37- ->willReturn (\ DateTimeImmutable::createFromFormat ('YmdHis ' , '20180508141454 ' ));
41+ ->willReturn (DateTimeImmutable::createFromFormat ('YmdHis ' , '20180508141454 ' ));
3842
3943 $ file = new Ftp ($ ftpClient , $ ftpFile , $ remotePath );
4044 $ this ->assertEquals ('foo.txt ' , $ file ->getFilename ());
4145 $ this ->assertEquals ('backups/foo.txt ' , $ file ->getPathname ());
4246 $ this ->assertEquals (102102 , $ file ->getSize ());
43- $ this ->assertEquals ( 1525788894 , $ file ->getMTime ());
47+ $ this ->assertTrue ( 1525780000 < $ file ->getMTime ());
4448 $ this ->assertEquals (true , $ file ->isWritable ());
4549
4650 $ file ->unlink ();
@@ -52,19 +56,19 @@ public function testFile()
5256 public function testDeleteFailure ()
5357 {
5458 $ this ->expectException ('phpbu\App\Exception ' );
55- $ ftpClient = $ this ->createMock (\ SebastianFeldmann \ Ftp \ Client::class);
59+ $ ftpClient = $ this ->createMock (Client::class);
5660 $ ftpClient ->expects ($ this ->once ())->method ('chHome ' );
5761 $ ftpClient ->expects ($ this ->once ())
5862 ->method ('__call ' )
59- ->will ($ this ->throwException (new \ Exception ));
63+ ->will ($ this ->throwException (new Exception ));
6064
6165 $ remotePath = 'backups ' ;
62- $ ftpFile = $ this ->createMock (\ SebastianFeldmann \ Ftp \ File::class);
66+ $ ftpFile = $ this ->createMock (File::class);
6367 $ ftpFile ->expects ($ this ->exactly (2 ))->method ('getFilename ' )->willReturn ('foo.txt ' );
6468 $ ftpFile ->expects ($ this ->once ())->method ('getSize ' )->willReturn (102102 );
6569 $ ftpFile ->expects ($ this ->once ())
6670 ->method ('getLastModifyDate ' )
67- ->willReturn (\ DateTimeImmutable::createFromFormat ('YmdHis ' , '20180508141454 ' ));
71+ ->willReturn (DateTimeImmutable::createFromFormat ('YmdHis ' , '20180508141454 ' ));
6872
6973 $ file = new Ftp ($ ftpClient , $ ftpFile , $ remotePath );
7074 $ file ->unlink ();
0 commit comments