当前位置: 首页>>代码示例>>PHP>>正文


PHP Filesystem::expects方法代码示例

本文整理汇总了PHP中Symfony\Component\Filesystem\Filesystem::expects方法的典型用法代码示例。如果您正苦于以下问题:PHP Filesystem::expects方法的具体用法?PHP Filesystem::expects怎么用?PHP Filesystem::expects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Symfony\Component\Filesystem\Filesystem的用法示例。


在下文中一共展示了Filesystem::expects方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testPrePersist

 /**
  * @dataProvider getEntity
  *
  * @param \PHPUnit_Framework_MockObject_MockObject $entity
  * @param string $filename
  */
 public function testPrePersist(\PHPUnit_Framework_MockObject_MockObject $entity, $filename)
 {
     $this->args->expects($this->once())->method('getEntity')->will($this->returnValue($entity));
     if ($entity instanceof Item || $entity instanceof Image) {
         /* @var $entity \PHPUnit_Framework_MockObject_MockObject|Item|Image */
         $time = $this->getMock('\\DateTime');
         $time->expects($this->once())->method('format')->with('Y/m/d/His/')->will($this->returnValue('some/path'));
         if ($entity instanceof Item) {
             $entity->expects($this->once())->method('getDateAdd')->will($this->returnValue($time));
         } else {
             $item = $this->getMock('\\AnimeDb\\Bundle\\CatalogBundle\\Entity\\Item');
             $entity->expects($this->once())->method('getItem')->will($this->returnValue($item));
             $item->expects($this->once())->method('getDateAdd')->will($this->returnValue($time));
         }
         $entity->expects($this->at(1))->method('getFilename')->will($this->returnValue($filename));
         if ($filename) {
             $entity->expects($this->at(2))->method('getFilename')->will($this->returnValue($filename));
         }
         if (strpos($filename, 'tmp') !== false) {
             $entity->expects($this->at(3))->method('getFilename')->will($this->returnValue($filename));
             $entity->expects($this->at(6))->method('getFilename')->will($this->returnValue('new_filename'));
             $entity->expects($this->once())->method('setFilename')->with('some/path' . pathinfo($filename, PATHINFO_BASENAME));
             $entity->expects($this->once())->method('getDownloadPath')->will($this->returnValue('web'));
             $this->fs->expects($this->once())->method('copy')->with($this->root . 'web/' . $filename, $this->root . 'web/new_filename', true);
         }
     } else {
         $entity->expects($this->never())->method('getFilename');
     }
     $this->listener->prePersist($this->args);
 }
开发者ID:anime-db,项目名称:catalog-bundle,代码行数:36,代码来源:DownloaderTest.php

示例2: testFileIsNotBackedUp

 public function testFileIsNotBackedUp()
 {
     $this->fs->expects($this->once())->method('exists')->with($this->yamlFile)->will($this->returnValue(true));
     $this->fs->expects($this->never())->method('copy');
     $this->fs->expects($this->once())->method('dumpFile')->with($this->phpFile, $this->php);
     $this->converter->convertFile($this->yamlFile, false);
 }
开发者ID:Dossar,项目名称:boltbse,代码行数:7,代码来源:ConverterTest.php

示例3: testLoadSavedObject

 public function testLoadSavedObject()
 {
     $className = uniqid('Tmp');
     $this->filesystem->expects($this->once())->method('exists')->with($this->equalTo('/tmp/' . $className . 'Serializer.php'))->will($this->returnValue(true));
     file_put_contents('/tmp/' . $className . 'Serializer.php', '<?php class ' . $className . 'Serializer {}');
     $serializer = $this->createCache()->load($className);
     $this->assertInstanceOf($className . 'Serializer', $serializer);
     unlink('/tmp/' . $className . 'Serializer.php');
 }
开发者ID:nickvkaam,项目名称:SpraySerializer,代码行数:9,代码来源:FileCacheTest.php

示例4: testCacheAction

 /**
  * Tests cacheAction() method.
  */
 public function testCacheAction()
 {
     // Given
     $this->filesystem->expects($this->once())->method('exists')->will($this->returnValue(true));
     $this->filesystem->expects($this->once())->method('remove');
     // When
     $response = $this->cache->cacheAction('token', 'translations');
     // Then
     $this->assertInstanceOf('Symfony\\Component\\HttpFoundation\\Response', $response);
     $this->assertEquals(200, $response->getStatusCode(), 'Response should be 200');
     $this->assertEquals('ok', $response->getContent(), 'Response should return "OK"');
     $this->assertEquals(2, $response->headers->get('Content-Length'));
     $this->assertEquals('must-revalidate, no-cache, private', $response->headers->get('Cache-Control'));
 }
开发者ID:LamaDelRay,项目名称:test_symf,代码行数:17,代码来源:SymfonyCacheTest.php

示例5: testRemoveFile

 /**
  * @dataProvider getOldFiles
  *
  * @param array $files
  */
 public function testRemoveFile(array $files)
 {
     $that = $this;
     $root = $this->root . 'bar/';
     $entity = $this->getMock('\\AnimeDb\\Bundle\\AppBundle\\Service\\Downloader\\Entity\\EntityInterface');
     $entity->expects($this->atLeastOnce())->method('getFilename')->will($this->returnValue('baz'));
     $entity->expects($this->atLeastOnce())->method('getDownloadPath')->will($this->returnValue('bar'));
     $entity->expects($this->once())->method('getOldFilenames')->will($this->returnValue($files));
     /* @var $args \PHPUnit_Framework_MockObject_MockObject|LifecycleEventArgs */
     $args = $this->getMockBuilder('\\Doctrine\\ORM\\Event\\LifecycleEventArgs')->disableOriginalConstructor()->getMock();
     $args->expects($this->atLeastOnce())->method('getEntity')->will($this->returnValue($entity));
     $this->fs->expects($this->atLeastOnce())->method('remove')->will($this->returnCallback(function ($file) use($files, $root, $that) {
         $filename = pathinfo($file, PATHINFO_BASENAME);
         if ($filename == 'baz') {
             // origin file
             $that->assertEquals($root . 'baz', $file);
         } else {
             // old files
             $that->assertContains($filename, $files);
             $that->assertEquals($root . $filename, $file);
         }
     }));
     // test
     $this->listener->postRemove($args);
 }
开发者ID:anime-db,项目名称:app-bundle,代码行数:30,代码来源:EntityTest.php

示例6: thatFileRemoves

 /**
  * @test
  */
 public function thatFileRemoves()
 {
     $this->fileInfo = $this->getFileInfoInstance(self::DUMMY_REAL_PATH, true, true);
     $this->localFileStorageService = $this->getLocalFileStorageServiceInstance($this->fileInfo);
     $this->fs->expects($this->once())->method('remove')->with($this->equalTo(self::DUMMY_REAL_PATH . DIRECTORY_SEPARATOR . self::DUMMY_FILENAME));
     $this->localFileStorageService->remove(self::DUMMY_FILENAME);
 }
开发者ID:gitter-badger,项目名称:diamantedesk-application,代码行数:10,代码来源:LocalFileStorageServiceTest.php

示例7: testConfirmException

 public function testConfirmException()
 {
     $this->request->expects($this->once())->method('get')->with('token')->willReturn('awesome-token');
     $this->filesystem->expects($this->once())->method('exists')->with(sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'awesome-token' . '.txt')->willReturn(true);
     $this->mollieAPIClient->payments = $this->payments;
     $this->payments->expects($this->once())->method('get')->with('test')->willThrowException(new Mollie_API_Exception());
     $this->assertFalse($this->mollieDriver->confirm($this->request));
 }
开发者ID:shivella,项目名称:ideal-bundle,代码行数:8,代码来源:MollieDriverTest.php

示例8: testRewriteWithNonexistentSourcePath

 /**
  * @expectedException \Lug\Component\Assetic\Exception\PathNotFoundException
  * @expectedExceptionMessage The asset "source_root/foo.jpg" could not be found.
  */
 public function testRewriteWithNonexistentSourcePath()
 {
     $asset = $this->createAssetMock();
     $asset->expects($this->once())->method('getSourceRoot')->will($this->returnValue($sourceRoot = 'source_root'));
     $asset->expects($this->exactly(2))->method('getSourcePath')->will($this->returnValue($sourcePath = 'source_path'));
     $asset->expects($this->once())->method('getTargetPath')->will($this->returnValue($targetPath = 'target_path'));
     $reference = $this->createReference($path = 'foo.jpg');
     $this->filesystem->expects($this->once())->method('exists')->with($this->identicalTo($sourceRoot . DIRECTORY_SEPARATOR . $path))->will($this->returnValue(false));
     $this->cssRewriter->rewrite($reference, $asset);
 }
开发者ID:blazarecki,项目名称:lug,代码行数:14,代码来源:CssRewriterTest.php

示例9: testDumpWithAnEntity

 /**
  * Tests the dump() method with an entity.
  */
 public function testDumpWithAnEntity()
 {
     if (!method_exists($this->filesystem, 'dumpFile')) {
         $this->markTestSkipped('Test skipped as Filesystem::dumpFile() is not available in this version.');
     }
     // Given
     $this->service->setRootDir('/unit/test/');
     $this->service->setFilename('feed.rss');
     $this->service->setEntity('Eko\\FeedBundle\\Tests\\Entity\\Writer\\FakeItemInterfaceEntity');
     $this->service->setDirection('ASC');
     $entity = $this->getMock('Eko\\FeedBundle\\Tests\\Entity\\Writer\\FakeItemInterfaceEntity');
     $repository = $this->getMockBuilder('Doctrine\\ORM\\EntityRepository')->disableOriginalConstructor()->getMock();
     $repository->expects($this->once())->method('findBy')->will($this->returnValue([$entity, $entity]));
     $this->entityManager->expects($this->once())->method('getRepository')->will($this->returnValue($repository));
     $feed = $this->getMockBuilder('Eko\\FeedBundle\\Feed\\Feed')->disableOriginalConstructor()->getMock();
     $feed->expects($this->once())->method('addFromArray');
     $feed->expects($this->once())->method('render')->will($this->returnValue('XML content'));
     $this->feedManager->expects($this->once())->method('get')->will($this->returnValue($feed));
     $this->filesystem->expects($this->once())->method('dumpFile')->with('/unit/test/feed.rss', 'XML content');
     // When - Expects actions
     $this->service->dump();
 }
开发者ID:eko,项目名称:feedbundle,代码行数:25,代码来源:FeedDumpServiceTest.php

示例10: testPostUpdate

 public function testPostUpdate()
 {
     $file1 = $this->root . 'foo/' . Storage::ID_FILE;
     $file2 = $this->root . 'bar/' . Storage::ID_FILE;
     $storage = $this->getMock('\\AnimeDb\\Bundle\\CatalogBundle\\Entity\\Storage');
     $storage->expects($this->atLeastOnce())->method('getId')->will($this->returnValue(123));
     $storage->expects($this->atLeastOnce())->method('getPath')->will($this->returnValue('baz'));
     $storage->expects($this->once())->method('getOldPaths')->will($this->returnValue([dirname($file1) . '/', dirname($file2) . '/']));
     $this->fs->expects($this->at(0))->method('exists')->will($this->returnValue(true))->with($file1);
     $this->fs->expects($this->at(2))->method('exists')->will($this->returnValue(true))->with($file2);
     $this->fs->expects($this->at(4))->method('exists')->will($this->returnValue(true))->with('baz');
     $this->fs->expects($this->at(5))->method('exists')->will($this->returnValue(false))->with('baz' . Storage::ID_FILE);
     $this->fs->expects($this->at(1))->method('remove')->with($file1);
     $this->fs->expects($this->at(3))->method('remove')->with($file2);
     $this->fs->expects($this->once())->method('dumpFile')->with('baz' . Storage::ID_FILE, 123, 0666);
     $this->real_fs->dumpFile($file1, 123);
     $this->real_fs->dumpFile($file2, 123);
     $this->storage->postUpdate($this->getArgs($storage));
 }
开发者ID:anime-db,项目名称:catalog-bundle,代码行数:19,代码来源:StorageTest.php

示例11: download

 /**
  * @param string $target
  * @param bool $is_successful
  * @param string $url
  */
 protected function download($target, $is_successful = true, $url = '')
 {
     $this->fs->expects($this->once())->method('mkdir')->with(dirname($target), 0755);
     $this->request->expects($this->once())->method('setResponseBody')->will($this->returnSelf())->with($target);
     $this->dialog($is_successful, $url);
 }
开发者ID:anime-db,项目名称:app-bundle,代码行数:11,代码来源:DownloaderTest.php

示例12: assertClearCache

 /**
  * @param string $path
  */
 protected function assertClearCache($path)
 {
     $this->fs->expects($this->once())->method('exists')->with($path)->willReturn(true);
     $this->fs->expects($this->once())->method('remove')->with($path);
 }
开发者ID:antrampa,项目名称:crm,代码行数:8,代码来源:WsdlManagerTest.php

示例13: testExecuteUpdateItself

 public function testExecuteUpdateItself()
 {
     $tag = ['name' => '1.1.0-alpha', 'zipball_url' => 'http://example.com/tags/1.0.1.zip'];
     $dispatcher = $this->getMock('\\Symfony\\Component\\EventDispatcher\\EventDispatcherInterface');
     $local_dispatcher = $this->getMockBuilder('\\AnimeDb\\Bundle\\AnimeDbBundle\\Event\\Dispatcher')->disableOriginalConstructor()->getMock();
     $package = $this->getMock('\\Composer\\Package\\RootPackageInterface');
     // vars for closures
     $that = $this;
     $fs = $this->fs;
     $root_dir = $this->root_dir;
     $target = $this->target;
     $root_package = $this->package;
     // create files for Finder
     $this->fs->mkdir([$this->root_dir . 'app/cache', $this->root_dir . 'app/DoctrineMigrations/', $this->root_dir . 'app/Resources/views/', $this->root_dir . 'app/config/', $this->root_dir . 'src/Tests/', $this->root_dir . 'src/Console']);
     $this->fs->touch([$this->root_dir . 'app/bootstrap.php.cache', $this->root_dir . 'app/DoctrineMigrations/Version11111111111111_Demo.php', $this->root_dir . 'app/Resources/views/base.html.twig', $this->root_dir . 'app/config/config.yml', $this->root_dir . 'src/AnimeDbAnimeDbBundle.php', $this->root_dir . 'src/Tests/TestCaseWritable.php']);
     // init command
     $command = $this->getCommandToExecute($tag, '1.0.0', 0);
     $this->write(['Discovered a new version of the application: <info>' . $tag['name'] . '</info>', '<info>Update itself has been completed</info>', '<info>Update requirements has been completed</info>', '<info>Updating the application has been completed<info>']);
     $this->container->expects($this->at(2))->method('get')->will($this->returnValue($this->filesystem))->with('filesystem');
     $this->container->expects($this->at(3))->method('get')->will($this->returnValue($dispatcher))->with('event_dispatcher');
     $this->container->expects($this->at(4))->method('get')->will($this->returnValue($this->filesystem))->with('filesystem');
     $this->container->expects($this->at(8))->method('get')->will($this->returnValue($local_dispatcher))->with('anime_db.event_dispatcher');
     $this->container->expects($this->atLeastOnce())->method('getParameter')->will($this->returnValue($this->root_dir . 'app'))->with('kernel.root_dir');
     $this->composer->expects($this->once())->method('download')->will($this->returnCallback(function ($package, $_target) use($that, $target, $tag) {
         $that->assertEquals($target, $_target);
         // check package
         /* @var $package Package */
         $that->assertInstanceOf('\\Composer\\Package\\Package', $package);
         $that->assertEquals('anime-db/anime-db', $package->getName());
         $that->assertEquals(Composer::getVersionCompatible($tag['name']), $package->getVersion());
         $that->assertEquals($tag['name'], $package->getPrettyVersion());
         $that->assertEquals('zip', $package->getDistType());
         $that->assertEquals($tag['zipball_url'], $package->getDistUrl());
         $that->assertEquals('dist', $package->getInstallationSource());
     }));
     $this->composer->expects($this->once())->method('getPackageFromConfigFile')->with($this->target . '/composer.json')->will($this->returnValue($package));
     $this->composer->expects($this->once())->method('reload');
     $dispatcher->expects($this->once())->method('dispatch')->will($this->returnCallback(function ($name, $event) use($that, $target, $package, $root_package) {
         $that->assertEquals(StoreEvents::DOWNLOADED, $name);
         // check event
         /* @var $event Downloaded */
         $that->assertInstanceOf('\\AnimeDb\\Bundle\\AnimeDbBundle\\Event\\UpdateItself\\Downloaded', $event);
         $that->assertEquals($target, $event->getPath());
         $that->assertEquals($package, $event->getNewPackage());
         $that->assertEquals($root_package, $event->getOldPackage());
     }));
     $local_dispatcher->expects($this->once())->method('dispatch')->will($this->returnCallback(function ($name, $event) use($that, $package) {
         $that->assertEquals(StoreEvents::UPDATED, $name);
         /* @var $event Updated */
         $that->assertInstanceOf('\\AnimeDb\\Bundle\\AnimeDbBundle\\Event\\UpdateItself\\Updated', $event);
         $that->assertEquals($package, $event->getPackage());
     }));
     $this->filesystem->expects($this->at(0))->method('remove')->with($this->target);
     $this->filesystem->expects($this->at(1))->method('remove')->will($this->returnCallback(function ($finder) use($that, $fs, $root_dir) {
         $that->assertInstanceOf('\\Symfony\\Component\\Finder\\Finder', $finder);
         // test remove files from Finder
         $fs->remove($finder);
         $that->assertFileExists($root_dir . 'app/bootstrap.php.cache');
         $that->assertFileExists($root_dir . 'app/DoctrineMigrations/Version11111111111111_Demo.php');
         $that->assertFileExists($root_dir . 'app/Resources/views/base.html.twig');
         $that->assertFileExists($root_dir . 'app/config');
         $that->assertFileExists($root_dir . 'src/Console');
         $that->assertFileNotExists($root_dir . 'app/config/config.yml');
         $that->assertFileNotExists($root_dir . 'src/AnimeDbAnimeDbBundle.php');
         $that->assertFileNotExists($root_dir . 'src/Tests/TestCaseWritable.php');
     }));
     $this->filesystem->expects($this->at(3))->method('remove')->with($this->target);
     $this->filesystem->expects($this->once())->method('mirror')->with($this->target, $this->root_dir . 'app/../', null, ['override' => true, 'copy_on_windows' => true]);
     $command->run($this->input, $this->output);
     // test
 }
开发者ID:anime-db,项目名称:anime-db,代码行数:71,代码来源:UpdateCommandTest.php


注:本文中的Symfony\Component\Filesystem\Filesystem::expects方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。