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(); }
/** * @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); }
/** * @test * @group issue/346 */ public function canMockInternalClassesThatImplementSerializable() { $mock = $this->container->mock("ArrayObject"); $this->assertInstanceOf("Serializable", $mock); }
public function testByDefaultOnAMockDoesSquatWithoutExpectations() { $container = new \Mockery\Container(\Mockery::getDefaultGenerator(), \Mockery::getDefaultLoader()); $mock = $container->mock('f')->byDefault(); }
/** * @param \Mockery\Container $container * @param string $method * @param Mockery\ExpectationInterface $exp * @return \Mockery\Mock */ private static function getNewDemeterMock(Mockery\Container $container, $method, Mockery\ExpectationInterface $exp) { $mock = $container->mock('demeter_' . $method); $exp->andReturn($mock); return $mock; }
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'); }
/** * 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); }
/** * */ 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'); }
/** * @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); }