コード例 #1
0
 public function testAddRecord()
 {
     $record = new Record();
     $record->directiveList()->add('allow:/allowed-path');
     $this->file->addRecord($record);
     $fileRecords = $this->file->getRecords();
     $this->assertEquals(1, count($fileRecords));
     $this->assertTrue($fileRecords[0] instanceof Record);
 }
コード例 #2
0
 public function testWithMultipleRecords()
 {
     $record1 = new Record();
     $record1->directiveList()->add('allow:/allowed-path');
     $record1->userAgentDirectiveList()->add('googlebot');
     $record2 = new Record();
     $record2->directiveList()->add('disallow:/');
     $record2->userAgentDirectiveList()->add('slurp');
     $this->file->addRecord($record1);
     $this->file->addRecord($record2);
     $this->assertEquals('user-agent:googlebot' . "\n" . 'allow:/allowed-path' . "\n\n" . 'user-agent:slurp' . "\n" . 'disallow:/', (string) $this->file);
 }
 public function setUp()
 {
     parent::setUp();
     $record1 = new Record();
     $record1->userAgentDirectiveList()->add('*');
     $record1->directiveList()->add('allow:/allowed-path-for-*');
     $record1->directiveList()->add('disallow:/disallowed-path-for-*');
     $record2 = new Record();
     $record2->userAgentDirectiveList()->add('googlebot');
     $record2->directiveList()->add('allow:/allowed-path-for-googlebot');
     $record2->directiveList()->add('disallow:/disallowed-path-for-googlebot');
     $this->file->addRecord($record1);
     $this->file->addRecord($record2);
 }
コード例 #4
0
 public function testGetDirectivesFor()
 {
     $record1 = new Record();
     $record1->userAgentDirectiveList()->add('*');
     $record1->directiveList()->add('allow:/allowed-path-for-*');
     $record1->directiveList()->add('disallow:/disallowed-path-for-*');
     $record2 = new Record();
     $record2->userAgentDirectiveList()->add('googlebot');
     $record2->directiveList()->add('allow:/allowed-path-for-googlebot');
     $record2->directiveList()->add('disallow:/disallowed-path-for-googlebot');
     $this->file->addRecord($record1);
     $this->file->addRecord($record2);
     $this->assertEquals('allow:/allowed-path-for-googlebot' . "\n" . 'disallow:/disallowed-path-for-googlebot', (string) $this->file->getDirectivesFor('googlebot'));
     $this->assertEquals('allow:/allowed-path-for-*' . "\n" . 'disallow:/disallowed-path-for-*', (string) $this->file->getDirectivesFor('*'));
     $this->assertEquals('allow:/allowed-path-for-*' . "\n" . 'disallow:/disallowed-path-for-*', (string) $this->file->getDirectivesFor('slurp'));
 }