public function testOnlyOneFileIsSavedPerRecordId() { $file1 = $this->getUploadedJpeg(); $file2 = $this->getUploadedJpeg(1); $recordId = 1; $savePath = Yii::app()->params['imgPath'] . '/' . OuterLinkImage::RECORD_TYPE . '/' . $recordId; $outerLinkImage = new OuterLinkImage(); $outerLinkImage->recordId = $recordId; $outerLinkImage->file = $file1; $this->assertTrue($outerLinkImage->validate(), 'cannot validate outerLinkImage'); $this->assertTrue($outerLinkImage->save(), 'cannot save outerLinkImage'); $this->assertFileExists($savePath); $this->assertFileExists($savePath . '/' . basename($file1)); $this->assertCount(1, glob($savePath . '/*')); $outerLinkImage = new OuterLinkImage(); $outerLinkImage->recordId = $recordId; $outerLinkImage->file = $file2; $this->assertTrue($outerLinkImage->validate(), 'cannot validate outerLinkImage'); $this->assertTrue($outerLinkImage->save(), 'cannot save outerLinkImage'); $this->assertFileExists($savePath); $this->assertFileExists($savePath . '/' . basename($file2)); $this->assertCount(1, glob($savePath . '/*')); }