Exemplo n.º 1
0
 public function setUp()
 {
     parent::setUp();
     $container = new \Mockery\Container();
     $app = $container->mock('\\Bluzman\\Application\\Application[getWorkingPath]')->shouldDeferMissing()->shouldAllowMockingProtectedMethods();
     $app->shouldReceive('getWorkingPath')->atLeast(1)->andReturn($this->workingPath)->getMock();
     $this->setApplication($app);
     $this->moduleName = $this->getFaker()->lexify();
 }
Exemplo n.º 2
0
 /**
  * @dataProvider templateOptions
  */
 public function testCompiledTemplate($templateOptions)
 {
     $container = new \Mockery\Container();
     $faker = \Faker\Factory::create();
     $filePath = $this->workingPath . DS . $faker->lexify . '.' . $faker->fileExtension;
     /**
      * @var $template AbstractTemplate
      */
     $template = $container->mock($templateOptions['template'])->shouldDeferMissing()->shouldAllowMockingProtectedMethods();
     $template->shouldReceive('getDefaultTemplateData')->atLeast(1)->andReturn($templateOptions['defaultTemplateData']);
     $template->setTemplateData($templateOptions['templateData']);
     $template->setFilePath($filePath);
     $generator = new Generator($template);
     $generator->setAbsolutePath(__DIR__ . DS . 'fixtures');
     $this->assertEquals($templateOptions['stub'], $generator->getCompiledTemplate());
     $generator->make();
     $this->assertFileExists($filePath);
 }
Exemplo n.º 3
0
 /**
  * @test
  * @group issue/346
  */
 public function canMockInternalClassesThatImplementSerializable()
 {
     $mock = $this->container->mock("ArrayObject");
     $this->assertInstanceOf("Serializable", $mock);
 }
Exemplo n.º 4
0
 /**
  * @dataProvider classNameProvider
  */
 public function testIsValidClassName($expected, $className)
 {
     $container = new \Mockery\Container();
     $this->assertSame($expected, $container->isValidClassName($className));
 }
Exemplo n.º 5
0
 public function testByDefaultOnAMockDoesSquatWithoutExpectations()
 {
     $container = new \Mockery\Container(\Mockery::getDefaultGenerator(), \Mockery::getDefaultLoader());
     $mock = $container->mock('f')->byDefault();
 }
Exemplo n.º 6
0
 /**
  * @param \Mockery\Container $container
  * @param string $demeterMockKey
  * @return mixed
  */
 private static function getExistingDemeterMock(Mockery\Container $container, $demeterMockKey)
 {
     $mocks = $container->getMocks();
     $mock = $mocks[$demeterMockKey];
     return $mock;
 }
Exemplo n.º 7
0
 public function testByDefaultOnAMockDoesSquatWithoutExpectations()
 {
     $container = new \Mockery\Container();
     $mock = $container->mock('f')->byDefault();
 }
 /** @test */
 public function shouldNotDuplicateDoublyInheritedMethods()
 {
     $container = new \Mockery\Container();
     $mock = $container->mock('Mockery\\Tests\\Evenement_EventEmitter', 'Mockery\\Tests\\Chatroulette_ConnectionInterface');
 }
Exemplo n.º 9
0
 /**
  * Testing exception create models
  *
  * @expectedException \Bluzman\Input\InputException
  */
 public function testValidateOptionException()
 {
     $container = new \Mockery\Container();
     $command = $container->mock('\\Bluzman\\Command\\Init\\ModelCommand[getPrimaryKey, getColumns]')->shouldDeferMissing()->shouldAllowMockingProtectedMethods();
     $command->shouldReceive('getPrimaryKey')->atLeast(1)->andReturn(null)->getMock();
     $command->shouldReceive('getColumns')->atLeast(1)->andReturn(null)->getMock();
     $this->getApplication()->addCommands([$command]);
     $commandTester = new CommandTester($command);
     $commandTester->execute(['command' => $command->getName(), '--name' => 'tes t', '--table' => $this->table], ['interactive' => false]);
     $this->assertEquals($this->getExpectedException(), 'InputException');
 }
 /** 
  * @test 
  * @group issue/339
  */
 public function canMockClassesThatImplementSerializable()
 {
     $mock = $this->container->mock("MockeryTest_ClassThatImplementsSerializable");
     $this->assertInstanceOf("Serializable", $mock);
 }
Exemplo n.º 11
0
 /**
  *
  */
 public function testWithCorrectParams()
 {
     $container = new \Mockery\Container();
     $commandMock = $container->mock('\\Bluzman\\Command\\Init\\AllCommand[getCmdPattern]', ['init:all'])->shouldDeferMissing()->shouldAllowMockingProtectedMethods();
     $commandMock->shouldReceive('getCmdPattern')->atLeast(1)->andReturn('mkdir %s')->getMock();
     $configMock = $container->mock('\\Bluzman\\Application\\Config[putOptions]', [$this->getApplication()])->shouldReceive('putOptions')->atLeast(1)->andReturn(true)->getMock();
     $this->assertInstanceOf('\\Bluzman\\Command\\Init\\AllCommand', $commandMock);
     $this->assertInstanceOf('\\Bluzman\\Application\\Config', $configMock);
     $this->getApplication()->addCommands([$commandMock]);
     $this->getApplication()->setConfig($configMock);
     $commandTester = new CommandTester($commandMock);
     $commandTester->execute(['command' => $commandMock->getName(), '--name' => $this->projectName, '--path' => $this->workingPath]);
     $display = $commandTester->getDisplay();
     $this->assertRegExp('/Running "init:all" command/', $display);
     $this->assertRegExp('/Cloning skeleton project/', $display);
     $this->assertRegExp('/has been successfully initialized/', $display);
     $this->assertFileExists($this->workingPath . DS . $this->projectName . DS . '.bluzman');
 }
Exemplo n.º 12
0
 /**
  * @test
  * @group issue/294
  * @expectedException Mockery\Exception\RuntimeException
  * @expectedExceptionMessage Could not load mock DateTime, class already exists
  */
 public function testThrowsWhenNamedMockClassExistsAndIsNotMockery()
 {
     $builder = new MockConfigurationBuilder();
     $builder->setName("DateTime");
     $mock = $this->container->mock($builder);
 }