r110732 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r110731‎ | r110732 | r110733 >
Date:05:26, 6 February 2012
Author:aaron
Status:ok
Tags:
Comment:
Added missing tests from r110731
Modified paths:
  • /trunk/phase3/tests/phpunit/includes/filerepo/FileBackendTest.php (modified) (history)

Diff [purge]

Index: trunk/phase3/tests/phpunit/includes/filerepo/FileBackendTest.php
@@ -779,6 +779,67 @@
780780 }
781781
782782 /**
 783+ * @dataProvider provider_testGetFileStat
 784+ */
 785+ public function testGetFileStat( $path, $content, $alreadyExists ) {
 786+ $this->backend = $this->singleBackend;
 787+ $this->tearDownFiles();
 788+ $this->doTestGetFileStat( $path, $content, $alreadyExists );
 789+ $this->tearDownFiles();
 790+
 791+ $this->backend = $this->multiBackend;
 792+ $this->tearDownFiles();
 793+ $this->doTestGetFileStat( $path, $content, $alreadyExists );
 794+ $this->tearDownFiles();
 795+ }
 796+
 797+ private function doTestGetFileStat( $path, $content, $alreadyExists ) {
 798+ $backendName = $this->backendClass();
 799+
 800+ if ( $alreadyExists ) {
 801+ $this->prepare( array( 'dir' => dirname( $path ) ) );
 802+ $status = $this->backend->create( array( 'dst' => $path, 'content' => $content ) );
 803+ $this->assertEquals( array(), $status->errors,
 804+ "Creation of file at $path succeeded ($backendName)." );
 805+
 806+ $size = $this->backend->getFileSize( array( 'src' => $path ) );
 807+ $time = $this->backend->getFileTimestamp( array( 'src' => $path ) );
 808+ $stat = $this->backend->getFileStat( array( 'src' => $path ) );
 809+
 810+ $this->assertEquals( strlen( $content ), $size,
 811+ "Correct file size of '$path'" );
 812+ $this->assertTrue( abs( time() - wfTimestamp( TS_UNIX, $time ) ) < 5,
 813+ "Correct file timestamp of '$path'" );
 814+
 815+ $size = $stat['size'];
 816+ $time = $stat['mtime'];
 817+ $this->assertEquals( strlen( $content ), $size,
 818+ "Correct file size of '$path'" );
 819+ $this->assertTrue( abs( time() - wfTimestamp( TS_UNIX, $time ) ) < 5,
 820+ "Correct file timestamp of '$path'" );
 821+ } else {
 822+ $size = $this->backend->getFileSize( array( 'src' => $path ) );
 823+ $time = $this->backend->getFileTimestamp( array( 'src' => $path ) );
 824+ $stat = $this->backend->getFileStat( array( 'src' => $path ) );
 825+
 826+ $this->assertFalse( $size, "Correct file size of '$path'" );
 827+ $this->assertFalse( $time, "Correct file timestamp of '$path'" );
 828+ $this->assertFalse( $stat, "Correct file stat of '$path'" );
 829+ }
 830+ }
 831+
 832+ function provider_testGetFileStat() {
 833+ $cases = array();
 834+
 835+ $base = $this->baseStorePath();
 836+ $cases[] = array( "$base/unittest-cont1/b/z/some_file.txt", "some file contents", true );
 837+ $cases[] = array( "$base/unittest-cont1/b/some-other_file.txt", "", true );
 838+ $cases[] = array( "$base/unittest-cont1/b/some-diff_file.txt", null, false );
 839+
 840+ return $cases;
 841+ }
 842+
 843+ /**
783844 * @dataProvider provider_testGetFileContents
784845 */
785846 public function testGetFileContents( $source, $content ) {
@@ -793,9 +854,6 @@
794855 $this->tearDownFiles();
795856 }
796857
797 - /**
798 - * @dataProvider provider_testGetFileContents
799 - */
800858 public function doTestGetFileContents( $source, $content ) {
801859 $backendName = $this->backendClass();
802860

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r110731In FileBackend:...aaron05:25, 6 February 2012

Status & tagging log