/**
  * @expectedException \Astina\Bundle\RedirectManagerBundle\Service\Exception\CsvImporterException
  */
 public function testIfExceptionIsRaisedWhenBadInputFileIsProvided()
 {
     $this->managerMock->expects($this->never())->method('persist');
     $this->managerMock->expects($this->never())->method('flush');
     $outputMock = $this->getMock('Symfony\\Component\\Console\\Output\\OutputInterface');
     $this->csvImporter->import($this->getCsvFilePath('bad-data'), 301, true, $outputMock);
 }
 /**
  * @dataProvider testValidateProvider
  * @param Map $map
  * @param array $repoMaps
  * @param boolean $expectation
  */
 public function testValidate(Map $map, $repoMaps, $expectation)
 {
     $mockContext = $this->getMockBuilder('stdClass')->setMethods(['addViolationAt'])->getMock();
     $mockContext->expects($this->any())->method('addViolationAt')->will($this->returnValue(true));
     $this->mapRepository->expects($this->any())->method('findForUrlOrPath')->will($this->returnValue($repoMaps));
     $this->assertEquals($expectation, $this->mapValidator->validate($map, $mockContext));
 }
 /**
  * {@inheritdoc}
  */
 public function setUp()
 {
     $this->parser = new AnnotationParser(new AnnotationReader());
     $builder = $this->getMockBuilder(ReflectionProperty::class);
     $builder->disableOriginalConstructor();
     $builder->setMethods(['getName', 'getDeclaringClass']);
     $this->property = $builder->getMock();
     //  Make sure the reflection property return this class.
     $this->property->expects($this->any())->method('getDeclaringClass')->willReturn(new ReflectionClass(get_called_class()));
 }
Esempio n. 4
0
 public function testBuildWithoutOutOfStock()
 {
     $scopeId = '113';
     $tableSuffix = 'scope113_someNamesomeValue';
     $index = 'test_index_name';
     $dimensions = [$this->createDimension('scope', $scopeId), $this->createDimension('someName', 'someValue')];
     $this->request->expects($this->exactly(2))->method('getDimensions')->willReturn($dimensions);
     $this->dimensionScopeResolver->expects($this->once())->method('getScope')->willReturn($this->scopeInterface);
     $this->scopeInterface->expects($this->once())->method('getId')->willReturn('someValue');
     $this->mockBuild($index, $tableSuffix, false);
     $this->stockConfiguration->expects($this->once())->method('getDefaultScopeId')->willReturn(1);
     $this->config->expects($this->once())->method('isSetFlag')->with('cataloginventory/options/show_out_of_stock')->will($this->returnValue(false));
     $this->connection->expects($this->once())->method('quoteInto')->with(' AND stock_index.website_id = ?', 1)->willReturn(' AND stock_index.website_id = 1');
     $this->select->expects($this->at(2))->method('where')->with('(someName=someValue)')->willReturnSelf();
     $this->select->expects($this->at(3))->method('joinLeft')->with(['stock_index' => 'cataloginventory_stock_status'], 'search_index.entity_id = stock_index.product_id' . ' AND stock_index.website_id = 1', [])->willReturnSelf();
     $this->select->expects($this->at(4))->method('where')->with('stock_index.stock_status = ?', 1)->will($this->returnSelf());
     $result = $this->target->build($this->request);
     $this->assertSame($this->select, $result);
 }
    private $rmethods;
    private $methods;
    public function __construct($name, $args = null)
    {
        $this->rclass = new ReflectionClass($name);
        $this->klass = $this->rclass->newInstance();
        $this->rmethods = $this->rclass->getMethods();
        $this->methods = array();
        foreach ($this->rmethods as $method) {
            if ($method->isPublic() && !$method->isStatic() && !$method->isConstructor()) {
                $this->methods[$method->getName()] = $method;
            }
        }
    }
    public function __call($method, $args)
    {
        if (in_array($method, array_keys($this->methods))) {
            return $this->methods[$method]->invoke($this->klass);
        }
    }
}
class Complex
{
    public function behave()
    {
        echo "shit!\n";
    }
}
$complex = new MockObject('Complex');
$complex->behave();
die;