Jump to content

Recommended Posts

Hello guys,

 

I need help with this:

public function getUserLogLines($logLines, $householdId) {

// Parse using parseLogLines

// Append result to userLogLines member

// Return userLogLines

}

 

So i should use previous function:

public function parseLogLines($logLines, $householdId) {

$matchingLines = "";

 

foreach(preg_split("/\n|\r/", $logLines) as $logLine) {

if (preg_match("/$householdId/", $logLine) > 0) {

$matchingLines .= trim($logLine) . "\n";

}

}

 

return trim($matchingLines);

}

to parse this:

function testParseLogLines() {

$logLine = "clientId:h-1-JG26D2S-s-0 refdata:sessionId: bv41h6ulfju3pg2sqe7j8r09f5;\r\n";

$logLine .= "This line doesn't contain the householdId\n";

$logLine .= "1-JG26D2S asd asd asd asas\n";

 

$expectedLogLines = "clientId:h-1-JG26D2S-s-0 refdata:sessionId: bv41h6ulfju3pg2sqe7j8r09f5;\n";

$expectedLogLines .= "1-JG26D2S asd asd asd asas";

$this->assertEquals($expectedLogLines, $this->logLiveView->parseLogLines($logLine, "1-JG26D2S"));

}

 

function testGetUserLogLines() {

$logLine = "clientId:h-1-JG26D2S-s-0 refdata:sessionId: bv41h6ulfju3pg2sqe7j8r09f5;\r\n";

$logLine .= "This line doesn't contain the householdId\n";

$logLine .= "1-JG26D2S asd asd asd asas\n";

 

$expectedLogLines = "clientId:h-1-JG26D2S-s-0 refdata:sessionId: bv41h6ulfju3pg2sqe7j8r09f5;\n";

$expectedLogLines .= "1-JG26D2S asd asd asd asas";

$this->assertEquals($expectedLogLines, $this->logLiveView->getUserLogLines($logLine, "1-JG26D2S"));

 

$logLine = "assd asd asdasdasdasd";

$this->assertEquals($expectedLogLines, $this->logLiveView->getUserLogLines($logLine, "1-JG26D2S"));

 

$logLine = "asdf asdasdas h-1-JG26D2S-s-0 asdasasdasd\n";

$logLine .= "1223445\n";

 

$expectedLogLines .= "asdf asdasdas h-1-JG26D2S-s-0 asdasasdasd\n";

$this->assertEquals($expectedLogLines, $this->logLiveView->getUserLogLines($logLine, "1-JG26D2S"));

}

 

Any suggetions on how to do it?

 

Thanks!

I don't really understand your question. The $this object exists to use methods from within an instantiated class object. To illustrate that, take a look at this example:

class Person
{
public function get_first_name()
{
	return 'John';
}

public function get_last_name()
{
	return 'Doe';
}

public function get_full_name()
{
	return $this->get_first_name() . $this->get_last_name();
}
}

Are you looking for something like the following (took a guess with the $userLogLines field):

 

public function getUserLogLines($logLines, $householdId) {   
      $this->userLogLines .= $this->parseUserLogLines($logLines, $householdId);
      return $userLogLines;
}

 

??

The first one worked, when i returned $this->userLogLines; and thanks for that!

 

Still need help, i need to make a comparison in that function that lines haven't multiplied.

 

	function testGetUserLogLines_SameLogLinesAreNotMultiplied() {
	$loglines = "3294051,Sun Jun 10 17:59:59 2012,NFO,HB,10.111.221.30,RealGoldRush2,h-1-JG26D2S-s0\n";
	$loglines .= "3294052,asdö  aölköaslklk,RealGoldRush2,h-1-JG26D2S-s0\n";
	$loglines .= "3294053,Sun Jun 10 17:59:59 2012,NFO,qwpjqwrepoqwe poqiwepoiqwe\n";

	$expectedLoglines = "3294051,Sun Jun 10 17:59:59 2012,NFO,HB,10.111.221.30,RealGoldRush2,h-1-JG26D2S-s0\n";
	$expectedLoglines .= "3294052,asdö  aölköaslklk,RealGoldRush2,h-1-JG26D2S-s0";

	$this->assertEquals($expectedLoglines, $this->schedulerLogLiveView->getUserLogLines($loglines, "1-JG26D2S"));		
	$this->assertEquals($expectedLoglines, $this->schedulerLogLiveView->getUserLogLines($loglines, "1-JG26D2S"));		
}

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.