Пример #1
0
 /**
  * @test
  * @runInSeparateProcess
  * @preserveGlobalState false
  */
 public function returnsTestResource()
 {
     $path = 'Foo/Bar.txt';
     $str = 'foobar';
     PHPMockery::mock(__NAMESPACE__, 'file_get_contents')->andReturn($str);
     $this->assertSame($str, static::$resourceProvider->getTestResource($path));
 }
Пример #2
0
 /**
  * @test
  * @group algorithmFactory
  */
 public function shouldReturnAsymmetricAlgorithm()
 {
     PHPMockery::mock(__NAMESPACE__, "base_path")->andReturn('/some/directory/or/other');
     $algorithmFactory = new AlgorithmFactory(array('algorithm' => 'ES256', 'secret' => '', 'privateKey' => '', 'publicKey' => ''));
     $algorithm = $algorithmFactory->make();
     $this->assertInstanceOf('Bendbennett\\JWT\\Algorithms\\algorithmInterface', $algorithm);
     $this->assertInstanceOf('Bendbennett\\JWT\\Algorithms\\AsymmetricAlgorithm', $algorithm);
 }
Пример #3
0
 /**
  * @test
  */
 public function minesAdventCoins()
 {
     PHPMockery::mock(__NAMESPACE__, 'md5')->andReturnUsing(function ($key) {
         if ($key == 'foo5') {
             return '00000a1hR0sicfrPkvc7XgkO01eoOghM';
         }
         return 'iQMU4kZAjXskKQ8q5egoZph0O07nhLUc';
     });
     $this->assertEquals(5, AdventCoinMiner::mine('foo'));
     \Mockery::close();
 }
Пример #4
0
 public function setUp()
 {
     PHPMockery::mock(__NAMESPACE__, "uniqid")->withAnyArgs()->andReturn('a1b2c3d4');
     $this->request = \Mockery::mock('Illuminate\\Http\\Request');
     $this->request->shouldReceive('url')->once()->andReturn('http://some.url.com');
     $this->payloadUtilities = \Mockery::mock('Bendbennett\\JWT\\Utilities\\PayloadUtilities');
     $this->payloadUtilities->shouldReceive('getIat')->once()->andReturn(1);
     $this->payloadUtilities->shouldReceive('getExp')->once()->andReturn(3601);
     $this->payloadUtilities->shouldReceive('getNbf')->once()->andReturn(1);
     $this->payloadValidator = \Mockery::mock('Bendbennett\\JWT\\Validators\\PayloadValidator');
 }
Пример #5
0
 public function setUp()
 {
     parent::setUp();
     $config = (require __DIR__ . '/../../config.php');
     $this->dbalMock = $this->mock('ANavallaSuiza\\Laravel\\Database\\Contracts\\Dbal\\AbstractionLayer');
     $this->relationFactoryMock = $this->mock('Anavel\\Crud\\Contracts\\Abstractor\\RelationFactory');
     $this->fieldFactoryMock = $this->mock('Anavel\\Crud\\Contracts\\Abstractor\\FieldFactory');
     $this->columnMock = $this->mock('Doctrine\\DBAL\\Schema\\Column');
     $this->generatorMock = $this->mock('Anavel\\Crud\\Contracts\\Form\\Generator');
     $this->getClassMock = PHPMockery::mock('Anavel\\Crud\\Abstractor\\Eloquent', 'get_class');
     $this->sut = \Mockery::mock(Model::class, [$config['Users'], $this->dbalMock, $this->relationFactoryMock, $this->fieldFactoryMock, $this->generatorMock])->makePartial();
 }
Пример #6
0
 public function setUp()
 {
     parent::setUp();
     $this->wrongConfig = (require __DIR__ . '/../../wrong-config.php');
     $this->relationMock = $this->mock('Illuminate\\Database\\Eloquent\\Relations\\Relation');
     $this->fieldFactoryMock = $this->mock('Anavel\\Crud\\Contracts\\Abstractor\\FieldFactory');
     $this->modelManagerMock = Mockery::mock('ANavallaSuiza\\Laravel\\Database\\Contracts\\Manager\\ModelManager');
     $this->requestMock = $this->mock('Illuminate\\Http\\Request');
     $this->getClassMock = PHPMockery::mock('Anavel\\Crud\\Abstractor\\Eloquent\\Relation\\Traits', 'get_class');
     \App::instance('Anavel\\Crud\\Contracts\\Abstractor\\ModelFactory', $modelFactoryMock = $this->mock('Anavel\\Crud\\Contracts\\Abstractor\\ModelFactory'));
     $modelFactoryMock->shouldReceive('getByClassName')->andReturn($this->modelAbstractorMock = $this->mock('Anavel\\Crud\\Contracts\\Abstractor\\Model'));
     $this->relationMock->shouldReceive('getRelated')->andReturn($this->relationMock);
 }
Пример #7
0
 /**
  * Tests passing by reference as described in Mockery's manual with Mockery::on().
  *
  * @test
  * @link http://docs.mockery.io/en/latest/reference/pass_by_reference_behaviours.html
  */
 public function testMockeryPassByReference()
 {
     PHPMockery::mock(__NAMESPACE__, "exec")->with("command", \Mockery::on(function (&$output) {
         $output = "output";
         return true;
     }), \Mockery::on(function (&$return_var) {
         $return_var = "return_var";
         return true;
     }))->once();
     exec("command", $output, $return_var);
     $this->assertEquals("output", $output);
     $this->assertEquals("return_var", $return_var);
 }
Пример #8
0
 function it_asks_which_task_to_update_if_more_than_one_existing_task_is_found()
 {
     $mock = PHPMockery::mock('\\Ttf\\Remaim', 'fgets')->andReturn('0');
     $issue = ['subject' => 'Test Subject', 'attachments' => [], 'status' => ['id' => 1, 'name' => 'Resolved'], 'description' => 'A random description of a task'];
     $this->conduit->shouldReceive('callMethodSynchronous')->with('maniphest.query', ['projectPHIDs' => ['PHID-project'], 'fullText' => 'A random description of a task'])->once()->andReturn([['id' => 1, 'statusName' => 'Resolved', 'title' => 'Test Subject', 'description' => 'A random description of a task'], ['id' => 2, 'statusName' => 'Open', 'title' => 'Similar Task Subject', 'description' => 'A random description of a task']]);
     ob_start();
     $this->findExistingTask($issue, 'PHID-project')->shouldReturn(['id' => 1, 'statusName' => 'Resolved', 'title' => 'Test Subject', 'description' => 'A random description of a task']);
     $prompt = ob_get_clean();
     expect($prompt)->toBe("Oops, I found more than one already existing task in phabricator.\nPlease indicate which one to update.\n[0] =>\t[ID]: T1\n\t[Status]: Resolved\n\t[Name]: Test Subject\n\t[Description]: A random description of a task\n[1] =>\t[ID]: T2\n\t[Status]: Open\n\t[Name]: Similar Task Subject\n\t[Description]: A random description of a task\nEnter the [index] of the task you would like to use:\n> ");
 }