Example #1
0
 public function testAdd()
 {
     $this->varReaderWriter->expects($this->once())->method('isExist')->willReturn(false);
     $this->varReaderWriter->expects($this->once())->method('writeFile');
     $this->logger->expects($this->once())->method('log')->with(\Psr\Log\LogLevel::ERROR, 'test1');
     $this->status->add('test1', \Psr\Log\LogLevel::ERROR);
 }
 protected function getCommandTester()
 {
     $this->application->add($this->command);
     $command = $this->application->find('phpci:create-build');
     $commandTester = new CommandTester($command);
     return $commandTester;
 }
Example #3
0
 /**
  * Test add log message
  */
 public function testAdd()
 {
     $configMock = $this->getMock(\Magelight\Config::class, [], [], '', false);
     \Magelight\Config::forgeMock($configMock);
     $configMock->expects($this->any())->method('getConfig')->with('global/log/file', \Magelight\Log::DEFAUL_LOG_FILE)->will($this->returnValue('application.log'));
     $this->log->expects($this->once())->method('writeMessage')->with($this->matchesRegularExpression("/[\\-\\:\\d]+\\s\\-\\serror/i"));
     $this->log->add('error');
 }
 /**
  * @return CommandTester
  */
 protected function getCommandTester()
 {
     $this->application->getHelperSet()->set($this->dialog, 'dialog');
     $this->application->add($this->command);
     $command = $this->application->find('phpci:create-admin');
     $commandTester = new CommandTester($command);
     return $commandTester;
 }
Example #5
0
 public function testAdd()
 {
     $id = 'test_id';
     $parentId = 'test_parent_id';
     $blockType = 'test_block_type';
     $options = ['test' => 'val'];
     $siblingId = 'test_sibling_id';
     $prepend = true;
     $this->layoutManipulator->expects($this->once())->method('add')->with($id, $parentId, $blockType, $options, $siblingId, $prepend);
     $result = $this->layoutBuilder->add($id, $parentId, $blockType, $options, $siblingId, $prepend);
     $this->assertSame($this->layoutBuilder, $result);
 }
Example #6
0
 public function testInstance()
 {
     $this->generateInstance();
     $this->testInstance->expects($this->any())->method('getType')->will($this->returnValue(self::class));
     $this->testInstance->add(0, $this);
     $this->testInstance->offsetSet(0, $this);
     $this->testInstance->push($this);
     $this->testInstance->unshift($this);
     try {
         $this->testInstance->offsetSet(0, $this->testInstance);
     } catch (Exception $e) {
         $this->assertTrue($e instanceof InvalidArgumentException);
     }
 }
Example #7
0
 /**
  * @covers Basics\Collection\TypedList::filter
  */
 public function testFilterWorksProperly()
 {
     $at0NotMatching = $this->expectItem();
     $at1Matching = $this->expectItem();
     $at2NotMatching = $this->expectItem();
     $at3NotMatching = $this->expectItem();
     $at4Matching = $this->expectItem();
     $at5NotMatching = $this->expectItem();
     $this->expectSuccessiveCallsOnIsExpectedType(6, true);
     $this->typedList->add($at0NotMatching);
     $this->typedList->add($at1Matching);
     $this->typedList->add($at2NotMatching);
     $this->typedList->add($at3NotMatching);
     $this->typedList->add($at4Matching);
     $this->typedList->add($at5NotMatching);
     $matcher = function (Item $item) use($at1Matching, $at4Matching) {
         if ($at1Matching === $item || $at4Matching === $item) {
             return true;
         }
         return false;
     };
     $result = $this->invokeUnreachableMethod($this->typedList, 'filter', array($matcher));
     $this->assertCount(2, $result);
     $this->assertSame(array($at1Matching, $at4Matching), $result);
 }
 /**
  * QueueShellTest::testRetry()
  *
  * @return void
  */
 public function testRetry()
 {
     $this->QueueShell->args[] = 'RetryExample';
     $this->QueueShell->add();
     $expected = 'This is a very simple example of a QueueTask and how retries work';
     $this->assertContains($expected, $this->out->output());
     $this->QueueShell->runworker();
     $this->assertContains('Job did not finish, requeued.', $this->out->output());
 }
 public function testUploadFailNoClass()
 {
     $filePath = dirname(__DIR__) . '/sample/Italy.png';
     $this->service->expects($this->once())->method('createMediaInstance')->with($filePath, $this->classUri, 'EN_en', 'Italy1.png')->willReturn('http://www.tao.lu/Ontologies/TAO.rdf#MyLink');
     //mock the fileInfo method
     $fileInfo = array('name' => 'myName', 'mime' => 'mime/type', 'size' => 1024);
     $this->mediaManagerManagement->expects($this->once())->method('getFileInfo')->with('http://www.tao.lu/Ontologies/TAO.rdf#MyLink')->willReturn($fileInfo);
     $success = $this->mediaManagerManagement->add($filePath, 'Italy1.png', $this->classUri);
     $this->assertInternalType('array', $success, 'Should be a file info array');
     $this->assertArrayNotHasKey('error', $success, 'upload doesn\'t succeed');
     $this->assertEquals($fileInfo, $success, 'Doesn\'t return the getFileInfo value');
 }
 /**
  * @test
  */
 public function findByParentAndNodeTypeIncludesAddedNodeInRepositoryAndRespectsWorkspaceAndDimensions()
 {
     $liveWorkspace = new Workspace('live');
     $nodeData = $this->getMockBuilder(NodeData::class)->disableOriginalConstructor()->getMock();
     $nodeData->expects($this->any())->method('getIdentifier')->will($this->returnValue('abcd-efgh-ijkl-mnop'));
     $nodeData->expects($this->any())->method('getPath')->will($this->returnValue('/foo/bar'));
     $nodeData->expects($this->any())->method('getDepth')->will($this->returnValue(2));
     $this->nodeDataRepository->add($nodeData);
     $dimensions = array('persona' => array('everybody'), 'language' => array('de_DE', 'mul_ZZ'));
     $nodeData->expects($this->atLeastOnce())->method('matchesWorkspaceAndDimensions')->with($liveWorkspace, $dimensions)->will($this->returnValue(true));
     $this->nodeDataRepository->expects($this->any())->method('getNodeDataForParentAndNodeType')->will($this->returnValue(array()));
     $this->nodeDataRepository->expects($this->once())->method('getNodeTypeFilterConstraintsForDql')->will($this->returnValue(array('excludeNodeTypes' => array(), 'includeNodeTypes' => array())));
     $result = $this->nodeDataRepository->findByParentAndNodeType('/foo', null, $liveWorkspace, $dimensions);
     $this->assertCount(1, $result);
     $fetchedNodeData = reset($result);
     $this->assertSame($nodeData, $fetchedNodeData);
 }
Example #11
0
 /**
  * @test
  * @expectedException \TYPO3\CMS\Extbase\Persistence\Exception\IllegalObjectTypeException
  */
 public function addChecksObjectType()
 {
     $this->repository->_set('objectType', 'ExpectedObjectType');
     $this->repository->add(new \stdClass());
 }
 /**
  * @test
  *
  * @expectedException \BadMethodCallException
  */
 public function addThrowsException()
 {
     $this->subject->add(new AbstractEntity());
 }